Opened 3 years ago
Last modified 3 years ago
#55426 new defect (bug)
Two Categories in one URL; Shows Posts that are in BOTH Categories doesn’t work
Reported by: | gooloode | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.9.3 |
Component: | Taxonomy | Keywords: | has-patch reporter-feedback |
Focuses: | Cc: |
Description
Hey,
so usually i was able to add two categories in the URL and it would only show Posts, that are listed in BOTH categories. The Link was always domain.com/category/cat1+cat2 and worked for years. When using that link it would only show the posts that are marked in BOTH categories.
But i just tried to look for a post this way and that simply doesn’t work anymore. It only uses the first Category and ignores the Seconds. Has there been a change in the WP Core that i’m not aware of and is there a way to get back to that?
Change History (12)
This ticket was mentioned in PR #2469 on WordPress/wordpress-develop by gooloonetwork.
3 years ago
#2
- Keywords has-patch added
Hey,
so usually i was able to add two categories in the URL and it would only show Posts, that are listed in BOTH categories. The Link was always domain.com/category/cat1+cat2 and worked for years. When using that link it would only show the posts that are marked in BOTH categories.
But i just tried to look for a post this way and that simply doesn’t work anymore. It only uses the first Category and ignores the Seconds. Has there been a change in the WP Core that i’m not aware of and is there a way to get back to that?
Trac ticket: [](https://core.trac.wordpress.org/ticket/55426)
#3
@
3 years ago
- Component changed from General to Taxonomy
- Severity changed from normal to critical
- Version changed from 5.9.2 to 5.9.3
Hey, so i think this is actually a major bug and limits extensively the way posts are shown to a reader and/or user or even customer. But currently no one seems to even look into this bug. Has anyone maybe a Quick Fix?
peterwilsoncc commented on PR #2469:
3 years ago
#4
I think this pull request was intended to be created as an issue as it merges the 5.7
branch in to trunk
which would be problematic.
There's no need to create an issue on GitHub as the issue created on trac is enough.
#5
@
3 years ago
- Keywords reporter-feedback added
- Severity changed from critical to normal
Are you able to try reproducing this on a fresh WordPress install running the Twenty Twenty-Two theme without any plugins?
I am unable to reproduce this on a vanilla WordPress install, ie one using a default theme without any plugins.
Visiting http://wp-dev.local/category/categorized+uncategorized/
on my development environment only shows the two posts in both categories. The SQL query produced is
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (5) AND tt1.term_taxonomy_id IN (1) ) AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish'))) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
I've tested this on both WordPress 5.9 and soon to be released WordPress 6.0. It uses a similar DB query but you can see and example of displaying two tags: dev and 6.0 on the make/core blog.
#6
@
3 years ago
Hi Peter,
i'm unable to create a hosting environment as both of my slots are in live-use. But maybe the List of Plugins and such may help. I use:
WPBruiser
301 Redirects Pro
Advanced Ads – PopUp and Layer Ads
Advanced Ads Pro
Advanced Ads – Sticky Ads
Advanced Ads – Tracking
Advanced Ads
Amazon Product In a Post
AnyComment
Code Snippets
Disable Admin Notices Individually
Disable/Remove Google Fonts
Easy Add Thumbnail
Easy Theme and Plugin Upgrades
Forminator Pro
GDPR Data Request Form
Glossary
Helpful
Stop Generating Unnecessary Thumbnails
MailPoet 3 Premium (New)
MailPoet 3 (New)
MyThemeShop Theme & Plugin Updater
Post SMTP
Real Cookie Banner
Schema & Structured Data for WP & AMP
Stop WP Emails Going to Spam
Advanced Editor Tools (previously TinyMCE Advanced)
TotalPoll – Lite
Two Factor
User Access Shortcodes
User Menus
White Label CMS
WP Force SSL
WP-PageNavi
WP Review Pro
WP Rocket
SEOPress
WP Statistics
Widget Disable
And the Code Snippets for my functions.php
https://drive.google.com/file/d/1sswH9DvdPGRvPlc_mfvWEGCv0moxvFyz/view?usp=sharing
#7
@
3 years ago
@gooloode - use the troubleshooting mode in the plugin at https://wordpress.org/plugins/health-check/. It'll deactivate and switch themes for your view only, letting visitors see your normal site. If the cat1+cat2 syntax then works, use the troubleshooting admin bar item to restore your theme and plugins, one at a time and re-testing, to narrow down the source of the problem.
I double checked the cat1+cat2 syntax on my 5.9.3 site and it is now working fine. I think I may have still been on 5.9.2 when I confirmed the problem earlier.
#8
@
3 years ago
Hi @bcworkz
I have activated it and turned off everything, but the issue is still the same. I tried to look for exclusively vegan handcreams (URL: www.gooloo.de/category/handpflege+vegan) but only the first Category was used, meaning that all hand creams we're shown; not only the vegan ones.
#10
follow-up:
↓ 11
@
3 years ago
I see what the discrepancy is now, the issue is in using multiple category terms on custom post type queries. Works fine on default 'post' post type, but not on custom types like 'product'. Plain vanilla 5.9.3 site, no plugins, Twenty twenty-one theme. I probably did this last time I confirmed, but failed to mention this key aspect of the failed query.
#11
in reply to:
↑ 10
@
3 years ago
Disregard, I was using an invalid term slug, underscore vs. hyphen confusion. Custom type works fine as well.
Replying to bcworkz:
I see what the discrepancy is now, the issue is in using multiple category terms on custom post type queries. Works fine on default 'post' post type, but not on custom types like 'product'. Plain vanilla 5.9.3 site, no plugins, Twenty twenty-one theme. I probably did this last time I confirmed, but failed to mention this key aspect of the failed query.
#12
@
3 years ago
@gooloode -- this isn't the right place for individual support. Since we cannot replicate your issue on our own sites, there's nothing we can fix in core code to help you here. I suggest starting a new topic in the Fixing WordPress forum. You may reference this ticket for context so you don't need to re-supply supporting information. Don't reply to your original forum topic since it's now way down the list and it's unlikely anyone will see new replies there.
Confirmed. SQL contains a
0=1
clause when category name contains a '+'.I thought a workaround would be to use "pre_get_posts" action to intercept "category_name" query vars containing a '+' and compose a "tax_query" arg instead using
'operator => 'AND',
. Same result, the SQL ends up with a0=1
clause.