[wp-trac] [WordPress Trac] #62401: WP_Query add extra JOINs after calling get_posts() with category__in in query arguments
WordPress Trac
noreply at wordpress.org
Fri Feb 7 07:23:30 UTC 2025
#62401: WP_Query add extra JOINs after calling get_posts() with category__in in
query arguments
--------------------------+------------------------------
Reporter: elancerteam | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 6.6.2
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by shahabdev):
One way to resolve this issue is to use tax_query instead of category__in.
The tax_query parameter gives you more control over how WordPress handles
multiple categories. Try this modification in your query:
{{{
$args['tax_query'] = [
[
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $selected_categories,
'operator' => 'IN',
],
];
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62401#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list