Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#31781 closed defect (bug) (worksforme)

Adding a query parameter that has same name as a CPT returns 404

Reported by: collizo4sky's profile Collizo4sky Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1.1
Component: Rewrite Rules Keywords: dev-feedback close
Focuses: Cc:


I have a CPT called demo and my payment processor for my shop pass add a demo GET parameter (which i used to confirm if payment was made from a sandbox account) to the callback/return url which leads to 404.


Say my website is and has a CPT demo

A url of this nature will leads to a 404

I was able to trace the bug to wp-includes/post.php Line 1413 to 1416 (i might be wrong though)

I don't fully understand the core code in that file hence i couldn't provide a patch.

Change History (3)

#1 @flixos90
9 years ago

  • Component changed from Posts, Post Types to Rewrite Rules
  • Keywords dev-feedback added

Hello @Collizo4sky, and thank you for the report. The issue you're having happens since the demo parameter in the URL is assumed to be the query var for the post type of the same name, you're right with the code example you mentioned.

When the %demo% rewrite tag is added, that URL parameter is basically reserved by WordPress and cannot used in any other way. I'm not familiar enough with rewrites to judge whether this can or cannot be resolved - maybe it is possible to adjust the regular expression so the parameter is not considered a post type parameter if the value definitely does not apply to the intended usage. I'll move this to the Rewrites section for now.

#2 @SergeyBiryukov
9 years ago

  • Keywords close added

query_var can be customized in the post type registration code if needed, it should be a unique value that does not clash with other parameters.

#3 @wonderboymusic
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

comment:2 is correct

Note: See TracTickets for help on using tickets.