Opened 7 years ago
Last modified 7 years ago
#42164 new defect (bug)
Conditional Tags not working when using ugly URL
Reported by: | petersplugins | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.8.2 |
Component: | Query | Keywords: | needs-patch needs-unit-tests needs-testing |
Focuses: | template | Cc: |
Description
When accessing a category archive via its pretty URL e.g.
example.com/category/whatever
the conditional tag
is_category()
returns true.
Accessing the same category archive via its ugly URL
example.com?cat=whatever
the conditional tag
is_category()
returns false.
I'm pretty sure this concerns other conditional tags too. This is not only a cosmetic flaw because it causes WP to use the wrong template. I've tested it with Twenty Seventeen and the homepage template was used in case of using an ugly URL.
Due tue the ugly URL always work independently of permalink settings this is a bug in my opinion.
Change History (3)
Note: See
TracTickets for help on using
tickets.
It looks like this is because in
parse_query()
,is_category
is only set if the$tax_query
has an'operator'
specified:And in
parse_tax_query()
, the'cat'
query arg doesn't end up using an operator:I don't know if this is expected behavior or not. Looking at the history of the
isset( $tax_query['operator'] )
condition might tell the tale.