[wp-trac] [WordPress Trac] #40166: query_vars bug sets is_home to false.
WordPress Trac
noreply at wordpress.org
Mon May 20 09:17:12 UTC 2019
#40166: query_vars bug sets is_home to false.
--------------------------+------------------------------
Reporter: avengers | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.7.3
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by lllor):
The issue is still in WP 5.2
But in order to trigger the issue, you don't have to create a custom query
var. Just query the homepage ("/") with one of the default public WP
query vars. Example:
http://yoursite.com/?exact
and you will land on the most recent posts page instead of the static page
you have set as homepage.
Replying to [comment:2 indextwo]:
> I'm getting exactly the same behaviour; ended up on ticket #25143 before
finding this. Problem described in previous ticket for `3.6` still exists
in `4.7.3` and as above: adding a query var via `query_vars` whilst having
a static page set as the homepage results in `is_home()` incorrectly
returning `true` and `is_front_page()` returning `false` when appending a
`$_GET` var to the URL. Remove the `query_vars` filter, and they behave as
expected.
>
> To double-check, I added `die('<h1>I AM TEH INDEX</h1>');` to my
`index.php` template (where my page template was normal) and I got the
`die()` rather than the regular page content when
`add_filter('query_vars', 'my_qv_func')` was enabled.
>
> It may be worth noting that this only happens ''if'' you add a custom
query var:
>
> {{{#!php
> <?php
> function my_qv_func($queryVars) {
> $queryVars[] = 'myqv';
> return $queryVars;
> }
> add_filter('query_vars', 'my_qv_func'); // Static homepage breaks
> }}}
>
>
> Remove the addition (but leave the filter in place) and it behaves as
expected:
>
> {{{#!php
> <?php
> function my_qv_func($queryVars) {
> //$queryVars[] = 'myqv';
> return $queryVars;
> }
> add_filter('query_vars', 'my_qv_func'); // Static homepage behaves as
expected
> }}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40166#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list