Opened 8 years ago
Last modified 6 years ago
#40166 new defect (bug)
query_vars bug sets is_home to false.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.7.3 |
Component: | Query | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Hi @boonebgorges, in reference to an older ticket - #25143 following is the issue i am facing.
Similar to the other ticket, when registering a query variable as follows:
<?php function wppbi_register_query_vars($vars){ $vars[] = get_option('wppbi_file_url_parameter'); return $vars; } add_filter('query_vars', 'wppbi_register_query_vars');
the is_home variable is set to false when visitng the homepage as such http://yoursite.com/?foo=1 while http://yoursite.com/ works perfectly.
Any solutions are appreciated.
Change History (3)
#3
in reply to:
↑ 2
@
6 years ago
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:
and you will land on the most recent posts page instead of the static page you have set as homepage.
Replying to 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 in4.7.3
and as above: adding a query var viaquery_vars
whilst having a static page set as the homepage results inis_home()
incorrectly returningtrue
andis_front_page()
returningfalse
when appending a$_GET
var to the URL. Remove thequery_vars
filter, and they behave as expected.
To double-check, I added
die('<h1>I AM TEH INDEX</h1>');
to myindex.php
template (where my page template was normal) and I got thedie()
rather than the regular page content whenadd_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 function my_qv_func($queryVars) { $queryVars[] = 'myqv'; return $queryVars; } add_filter('query_vars', 'my_qv_func'); // Static homepage breaksRemove the addition (but leave the filter in place) and it behaves as expected:
<?php function my_qv_func($queryVars) { //$queryVars[] = 'myqv'; return $queryVars; } add_filter('query_vars', 'my_qv_func'); // Static homepage behaves as expected
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 in4.7.3
and as above: adding a query var viaquery_vars
whilst having a static page set as the homepage results inis_home()
incorrectly returningtrue
andis_front_page()
returningfalse
when appending a$_GET
var to the URL. Remove thequery_vars
filter, and they behave as expected.To double-check, I added
die('<h1>I AM TEH INDEX</h1>');
to myindex.php
template (where my page template was normal) and I got thedie()
rather than the regular page content whenadd_filter('query_vars', 'my_qv_func')
was enabled.It may be worth noting that this only happens if you add a custom query var:
Remove the addition (but leave the filter in place) and it behaves as expected: