• Resolved dizajner

    (@dizajner)


    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

    • This topic was modified 10 months ago by dizajner.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP Smart Widgets

    (@nomade123456)

    Hi @dizajner,

    Thank you for your feedback.

    At the moment, the plugin doesn’t let users define the relation between taxonomy groups mostly due to UI constraints. The AND/OR logic in each row defines the relation within a group, and then groups are paired together based on their relationship type. Introducing control over the relation between groups would mean allowing nested logical structures, which becomes difficult to represent clearly in the interface.

    One way I could support this would be to add a control that lets users define the relation between group blocks, essentially allowing a global relation between all AND/OR blocks. This would affect all the nested groups, but it might cover more use cases like the one you described.

    That said, this isn’t the first time I’ve had this request, so I’ll definitely keep thinking about a logical and user-friendly way to implement it in a future update.

    Thanks again for taking the time to share your thoughts.

    Regards,
    Dara

    Thread Starter dizajner

    (@dizajner)

    Hi Dara,

    Thank you for your feedback and analysis.

    Can you reply to this message and close this ticket when this plugin modification is deployed? (ASAP I hope 🙂 )

    Cheers

    Plugin Author WP Smart Widgets

    (@nomade123456)

    Hi @dizajner,

    Just a quick update, your request is now fully supported as of v1.5.0. The plugin now handles multiple taxonomy groups using a cleaner tax_query structure, just like the logic you outlined.

    Thanks for the suggestion.

    Cheers,
    Dara

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Condition multiples taxonomies’ is closed to new replies.