Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Tag search option
This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko 1 year, 5 months ago.
- AuthorPosts
- October 9, 2021 at 7:01 am #35104
Hello. What settings do I need to make to get this tag search option?
October 9, 2021 at 7:21 am #35105I have posts with tags. I need to set up a tag search. But not quite standard.
For example, there is a post in which 3 tags are added. For example:Potatoes, carrots, eggs. If you enter “potato” in the search and press Enter, then posts by this tag are shown. Then I type “carrot” and press Enter and get a post that has both “potato” and “carrot” tags. How do I set up this search option?
October 9, 2021 at 9:43 am #35110Hi,
I don’t know if this is possible – because only typing the keyword “carrot” there is no way for the plugin to know you also mean “potato”.
Depending on how you want to restrict the results, you can try a restriction by post tags, but that will apply to all search phrases.Another sort of a “hacky” way is to try keyword replacements programmatically via this tutorial. You could add rule so when “carrot” keyword is typed, it is replaced with “potato carrot”.
Best,
'carrot' => 'potato carrot',
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 10, 2021 at 10:11 am #35112You probably didn’t quite understand me correctly. The screenshot example will make everything clear
Attachments:
You must be logged in to view attached files.October 11, 2021 at 1:16 pm #35124For that layout it is not possible via settings, but might be doable via custom code.
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.
Best,add_filter( 'asp_query_args', 'asp_change_tag_logic_filters', 10, 2 ); function asp_change_tag_logic_filters( $args, $id ) { foreach ( $args['post_tax_filter'] as $fk => &$fv ) { if ( $fv['taxonomy'] == 'post_tag' ) { $fv['logic'] = 'AND'; $fv['_post_tags_empty'] = false; } } return $args; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 12, 2021 at 6:51 am #35130Thank you very much! Can you tell me what settings I need to make to display the same search block on my site?
https://ajaxsearchpro.com/filters-without-search-bar/
Attachments:
You must be logged in to view attached files.October 12, 2021 at 7:11 am #35133I am interested in multiple select
October 12, 2021 at 9:33 am #35137Sure! For post tags, you can set it here: https://i.imgur.com/Bxqcf1J.png
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 12, 2021 at 10:19 am #35138Anyway, the plugin doesn’t work the way it does on https://ajaxsearchpro.com/filters-without-search-bar/
Please see the screenshots
Attachments:
You must be logged in to view attached files.October 12, 2021 at 1:25 pm #35140If you need only the filters without the search bar, then this option will help you with that.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.