Opened 3 years ago
Last modified 3 years ago
#54258 new defect (bug)
WP_Query::is_tax() returns true on custom post type archives (5.8.1)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.8.1 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
I was testing the upgrade to 5.8.1 (from 5.7.3) on a copy of my (Lightsail/Bitnami-hosted) live instance and found that after upgrading to 5.8.1, a post_type=<type>
parameter is added to the URL when I navigate away from a page that displays posts from one of my custom post types. This happens whether or not I update plugins and themes.
E.g. I visit /photographs
, then click to go to /quotes
; post_type=photos
gets added to the URL (i.e. /quotes/?post_type=photos
) and it continues displaying photographs instead of quotes.
This happens both with my custom post types defined through the CPT plugin and with the ones I've defined in my own code. The parameter is not added when navigating away from standard post results.
Even if the parameter didn't interfere with the website's behavior, it would be a bug, as it's adding unnecessary and unwanted clutter to my URLs, but it does interfere and is a breaking change.
Change History (7)
#3
@
3 years ago
I've just tested removing each of those two from the condition that causes the parameter to be added in my function; it is the WP_Query::is_tax()
method that is now returning true.
#4
in reply to:
↑ 1
;
follow-up:
↓ 5
@
3 years ago
Replying to arestelle:
I'm looking into my custom theme code and I do have a function that applies this parameter, but only when the current query is a custom taxonomy or a search. I suspect either the
WP_Query::is_tax()
orWP_Query::is_search()
is now returning true on custom post type archive pages.
Please mention your theme function here that adds the parameter as reference. Without seeing anycode no one will be able to identify what is the actual problem.
#5
in reply to:
↑ 4
@
3 years ago
Replying to sabbirshouvo:
Please mention your theme function here that adds the parameter as reference. Without seeing any code no one will be able to identify what is the actual problem.
I identified it myself in the next comment; but the function is here. I removed || $query->is_search()
from the condition to no effect, then added that back and removed $query->is_tax() ||
and the parameter was no longer unexpectedly added.
#6
@
3 years ago
- Summary changed from post_type query parameter added to url causes incorrect type search results (5.8.1) to WP_Query::is_tax() returns true on custom post type archives (5.8.1)
I'm looking into my custom theme code and I do have a function that applies this parameter, but only when the current query is a custom taxonomy or a search. I suspect either the
WP_Query::is_tax()
orWP_Query::is_search()
is now returning true on custom post type archive pages.