[wp-trac] [WordPress Trac] #16373: Wrong page loaded requesting custom registered query_vars when correcting is_* for page_on_front requests

WordPress Trac noreply at wordpress.org
Sun Jan 19 01:27:10 UTC 2014


#16373: Wrong page loaded requesting custom registered query_vars when correcting
is_* for page_on_front requests
-------------------------------------------------+-------------------------
 Reporter:  jondavis                             |       Owner:
     Type:  defect (bug)                         |  markjaquith
 Priority:  high                                 |      Status:  reopened
Component:  Query                                |   Milestone:
 Severity:  normal                               |     Version:  3.0
 Keywords:  has-patch 3.3-early needs-unit-      |  Resolution:
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by Otto42):

 I'm kinda confused here with this:

 > where the query variables aren't intended to modify the loop query

 If the variables aren't intended to modify the main Loop, then they don't
 actually need to be registered as query_vars, do they?

 The only thing registering a query_var does is to make the main Query pick
 it up and store it and have it available via get_query_var and such. Not
 registering it doesn't make a variable in the URL unavailable, as it's
 still there via the GET global and so forth.

 So, the only reason to register a query_var is to have it available to the
 main query in some way, which would then be used to change the results of
 the main query, thus affecting the main Loop.

 I think that this problem is primarily caused by people using the
 query_var system as an general means of grabbing data from the URL, when
 that isn't really the main intention of it. PHP already has ways to grab
 data from the URL, the query_var stuff is there to ''affect the query'',
 not for any other purpose.

 Try simply not registering your input URL variables as query_vars, unless
 they are affecting the Loop. Then they won't impact anything.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/16373#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list