Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › AND logic between post tag multiselect
- This topic has 3 replies, 2 voices, and was last updated 5 years, 1 month ago by
Ernest Marcinko.
-
AuthorPosts
-
April 28, 2021 at 8:40 am #32959
yair07
ParticipantI am trying to implement a post tag multiselect filter to narrow down the search to only the selected tags. for example when a user selects the tag “Friendly people” and also the tag “Beach” I want the search results to show only destinations which have the tags “Friendly people” AND “Beach”.
This is a simple AND logic but it seems that it can’t be implemented. I’ve tried every possible combination of the settings “Taxonomy terms checkbox/multiselect connection logic” and “Logic between taxonomy groups” but it still always displays destination that have at least one of the tags (OR).
Why isn’t this working, an I missing something crucial?Thanks.
April 28, 2021 at 10:06 am #32963Ernest Marcinko
KeymasterHi,
There is no option for that unfortunately, the logic automatically falls back to “OR” when using the multiselect. There still might be a way to force it programmatically.
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
add_filter("asp_query_args", "asp_query_args_change1", 10, 2); function asp_query_args_change1($args, $search_id) { foreach ($args['post_tax_filter'] as $k => &$item) { if ( $item['taxonomy'] == 'post_tag' ) { $item['logic'] = 'andex'; } } return $args; }April 28, 2021 at 1:03 pm #32969yair07
ParticipantThat worked beautifully, Thanks!
I would recommend adding this feature to the plugin since I am sure this is a function many users might need.
April 28, 2021 at 2:22 pm #32976Ernest Marcinko
KeymasterWe surely will, the filters section is currently at major rework, it is already in there 🙂 We hope to release it within the next couple of months.
If you don’t mind, I will close this topic soon and mark it as resolved, feel free to open another one if you have other questions or issues.
If you like the plugin and have not rated already, feel free to leave a rating on your codecanyon downloads page, it’s greatly appreciated.
-
AuthorPosts
- You must be logged in to reply to this topic.