[wp-trac] [WordPress Trac] #25143: Appending registered query vars to home URL sets is_home to true when should be false

WordPress Trac noreply at wordpress.org
Fri Apr 3 03:07:57 UTC 2015

#25143: Appending registered query vars to home URL sets is_home to true when
should be false
 Reporter:  mordauk                       |       Owner:
     Type:  defect (bug)                  |      Status:  reopened
 Priority:  normal                        |   Milestone:  Future Release
Component:  Query                         |     Version:  3.6
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:

Comment (by mordauk):

 I believe I've found a way to fix this that (as far as I have found) does
 not have any negative consequences.

 It's a two step process.

 1. First setup an array of the default query vars that WordPress registers

 2. Inside of the existing `if ( $this->is_home && 'page' ==
 get_option('show_on_front') && get_option('page_on_front') ) {`
 conditional, we add a second conditional for when `$_query` is not empty,
 meaning there is a query var on the home page, but one that WordPress core
 doesn't do anything with. We then loop through the query vars in `$_query`
 and check that none of them are default query vars from WordPress. If none
 of them are, that means we are dealing with a query var that has been
 registered by a plugin. In this case, WordPress should NOT be changing the
 default behavior since it does not know what the proper behavior for that
 query var is.

 This patch is contingent on the idea that WordPress should more or less
 ignore query vars in the query that are not directly tied to a core
 behavior (front page, taxonomy, page, etc). When a plugin registers their
 query var, it is their responsibility to modify the query appropriately in
 order to get their results.

 The biggest concern I have with this change is the possibility of plugins
 breaking that have registered a query var and are then doing something
 with it on the home page. As of now, they may be accustomed to getting the
 blog page when their query vars are present. With this patch, they would
 get the static front page (if one is configured).

 I have tested the patch against several of my own plugins that register
 custom query vars and it successfully fixes the problem for them, without
 any break points.

Ticket URL: <https://core.trac.wordpress.org/ticket/25143#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list