Title: AND / OR functionality
Last modified: June 25, 2025

---

# AND / OR functionality

 *  Resolved [jomo5280](https://wordpress.org/support/users/jomo5280/)
 * (@jomo5280)
 * [11 months ago](https://wordpress.org/support/topic/and-or-functionality/)
 * I have hundreds of taxonomies and am seeing and issue on my end.
 * I have taxonomy group of Service 1, Service 2, Service 3 and then another group
   Gold, Silver, Bronze – If I select Service 2 and Bronze, It should filter all
   posts with those two common taxonomies selected. However, on my end – If I select
   Service 2, and Silver – it shows other Silver, and other Gold, Bronze taxonomies.
   I have “AND” selected on all my widget filters. Is there something I am doing
   wrong on my end or is it a bug? thank you again!!!!!!!

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

 *  Plugin Author [WP Smart Widgets](https://wordpress.org/support/users/nomade123456/)
 * (@nomade123456)
 * [11 months ago](https://wordpress.org/support/topic/and-or-functionality/#post-18528364)
 * Hi [@jomo5280](https://wordpress.org/support/users/jomo5280/),
 * Could you please double check that under each taxonomy group > advanced, the 
   group relation is set to “AND” then the “parent logic”, under “parent option”
   is also set to “AND”?
 * When configured this way, the resulting query should look something like this:
 *     ```
       [tax_query] => Array
       (
           [relation] => AND --This would come from the parent option
           [0] => Array
               (
                   [relation] => AND --This would come from the group relation option
                   [0] => Array
                       (
                           [taxonomy] => category
                           [field] => id
                           [terms] => 1
                           [include_children] => 1
                       )
                   [1] => Array
                       (
                           [taxonomy] => category
                           [field] => id
                           [terms] => 169
                           [include_children] => 1
                       )
                   [2] => Array
                       (
                           [taxonomy] => category
                           [field] => id
                           [terms] => 14259
                           [include_children] => 1
                       )
               )
           [1] => Array
               (
                   [relation] => AND --This would come from the group relation option
                   [0] => Array
                       (
                           [taxonomy] => post_tag
                           [field] => id
                           [terms] => 171
                           [include_children] => 1
                       )
                   [1] => Array
                       (
                           [taxonomy] => post_tag
                           [field] => id
                           [terms] => 14260
                           [include_children] => 1
                       )
               )
       )
       ```
   
 * Also keep in mind: if you’re using separate filter widgets on the same page (
   all targeting the same post widget), their selections will be combined in the
   final query. So multiple active filters will apply cumulatively.
 * If you’re still seeing unexpected results, feel free to reach out to me directly
   at [info@wpsmartwidgets.com](https://wordpress.org/support/topic/and-or-functionality/info@wpsmartwidgets.com?output_format=md).
   I’d need to enable the debug log on your site to inspect the exact query being
   generated.
 * Thanks,
    Dara
 *  [wheeldj](https://wordpress.org/support/users/wheeldj/)
 * (@wheeldj)
 * [10 months, 3 weeks ago](https://wordpress.org/support/topic/and-or-functionality/#post-18543062)
 * I’m seeing a similar issue with the filter widget on my site. Setting the Parent
   Logic field to **AND **on the filter widget is not working as described in the
   documentation.
   I have two filters added to the widget, both taxonomy data sources(
   category and tag). I want the filter to work so that when I select **category1**
   and also **tag1** and** tag2** it will show me _only _those posts in category1
   with _either _tag1 or tag2. however it is also returning any post for any of 
   the other categories that also have tag1 or tag2, even though the Parent Logic
   option is set to AND.
 * Is this a bug or have I misconfigured?
 *  Plugin Author [WP Smart Widgets](https://wordpress.org/support/users/nomade123456/)
 * (@nomade123456)
 * [10 months, 3 weeks ago](https://wordpress.org/support/topic/and-or-functionality/#post-18543144)
 * Hi [@wheeldj](https://wordpress.org/support/users/wheeldj/),
 * Thanks for the report. The Parent Logic setting is responsible for the relationship
   between AND/OR groups, which I realize might not be what most users expect. To
   address this, I’ve added a new control in the next version that will let users
   decide the relation between OR groups.
 * Right now, your query would look something like this:
 *     ```
       (
           [order] => ASC
           [orderby] => date
           [post_type] => post
           [paged] => 1
           [tax_query] => Array
               (
                   [relation] => AND  // Parent Logic
                   [0] => Array
                       (
                           [relation] => OR  // Concatenated OR Group Logic
                           [0] => Array
                               (
                                   [taxonomy] => category
                                   [field] => id
                                   [terms] => Array(14259, 14262)
                                   [include_children] => 1
                               )
                           [1] => Array
                               (
                                   [taxonomy] => post_tag
                                   [field] => id
                                   [terms] => Array(171, 14260)
                                   [include_children] => 1
                               )
                       )
               )
       )
       ```
   
 * In the meantime, you can try setting the group logic on your post categories 
   to AND so it splits the groups, or as a workaround, you can comment out the line
   330 of the class-jax.php file.
 * // $args[‘tax_query’][] = array_merge( [ ‘relation’ => ‘OR’ ], $query_or );
 * If you run into any other issues or need further assistance, please let me know.
 * Regards,
    Dara
 *  [wheeldj](https://wordpress.org/support/users/wheeldj/)
 * (@wheeldj)
 * [10 months, 3 weeks ago](https://wordpress.org/support/topic/and-or-functionality/#post-18543767)
 * Thanks Dara – You’re right that’s not what I would have expected, but good to
   know. Thanks for the super speedy answer!
   Do you have a rough idea when the new
   version will be available? (I’m not a web coder so trying to figure out whether
   it’s worth me hacking around in the files or just waiting for the next release!!)
   Thanks again!Jamie.
 *  Plugin Author [WP Smart Widgets](https://wordpress.org/support/users/nomade123456/)
 * (@nomade123456)
 * [10 months, 3 weeks ago](https://wordpress.org/support/topic/and-or-functionality/#post-18543872)
 * Hi Jamie,
 * I would expect the new release to be ready later this week. I’m currently testing
   all the most recent changes to make sure everything is stable before pushing 
   it live.
 * If you’re not in a rush, I’d recommend holding off rather than modifying the 
   file manually, especially since the upcoming version already addresses the issue
   you ran into. But if you need a quick workaround in the meantime, feel free to
   let me know and I’ll guide you through it.
 * Thanks again for your patience!
 * Regards,
    Dara
 *  Plugin Author [WP Smart Widgets](https://wordpress.org/support/users/nomade123456/)
 * (@nomade123456)
 * [10 months, 3 weeks ago](https://wordpress.org/support/topic/and-or-functionality/#post-18551128)
 * Hi [@jomo5280](https://wordpress.org/support/users/jomo5280/) and [@wheeldj](https://wordpress.org/support/users/wheeldj/),
 * Just confirming that this issue should now be resolved in v1.5.0. The update 
   introduces a cleaner tax_query structure and follow more closely the parent logic.
 * I’ll go ahead and mark this thread as resolved, but feel free to reopen or start
   a new one if you run into anything else.
 * Thanks again for your feedbacks.
 * Best,
    Dara

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

The topic ‘AND / OR functionality’ is closed to new replies.

 * ![](https://ps.w.org/better-post-filter-widgets-for-elementor/assets/icon.svg?
   rev=3235982)
 * [Better Post & Filter Widgets for Elementor](https://wordpress.org/plugins/better-post-filter-widgets-for-elementor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/better-post-filter-widgets-for-elementor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/better-post-filter-widgets-for-elementor/)
 * [Active Topics](https://wordpress.org/support/plugin/better-post-filter-widgets-for-elementor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/better-post-filter-widgets-for-elementor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/better-post-filter-widgets-for-elementor/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [WP Smart Widgets](https://wordpress.org/support/users/nomade123456/)
 * Last activity: [10 months, 3 weeks ago](https://wordpress.org/support/topic/and-or-functionality/#post-18551128)
 * Status: resolved