Condition multiples taxonomies
-
Hello,
Thank you for this plugin, which helps me with my custom post type filter system.
I noticed a gap in the filter settings.
My configuration
One CPT:
- Products
Two taxonomies associated with Product :
- Category
- Collection
If I check one or more categories AND one or more collections, I need to have the products in category A or B AND collection A or B, as follows:
$args = [
'post_type' => 'products',
'posts_per_page' => -1,
'tax_query' => [
'relation' => 'AND', // Relationship between taxonomies
// Taxonomy : category
[
'taxonomy' => 'category',
'field' => 'slug',
'terms' => ['handles', 'door'],
'operator' => 'IN',
],
// Taxonomy : collection
[
'taxonomy' => 'collection',
'field' => 'slug',
'terms' => ['gothique', 'empire'],
'operator' => 'IN',
],
],
];I had to modify code line 329 of the class-bpfwe-ajax.php file as follows for this to work.
// Add the OR group using combined terms with IN comparison.
if ( ! empty( $query_or ) && count( $query_or ) > 1 ) {
//$args['tax_query'][] = array_merge( [ 'relation' => 'OR' ], $query_or );
$args['tax_query'][] = $query_or;
} elseif ( ! empty( $query_or ) ) {
$args['tax_query'][] = $query_or[0];
}Can you add an option in the plugin to match this logic?
Cheers
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Condition multiples taxonomies’ is closed to new replies.