Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Tag search option
- This topic has 9 replies, 2 voices, and was last updated 4 years, 7 months ago by
Ernest Marcinko.
-
AuthorPosts
-
October 9, 2021 at 7:01 am #35104
OXYGEN12
ParticipantHello. What settings do I need to make to get this tag search option?
October 9, 2021 at 7:21 am #35105OXYGEN12
ParticipantI 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 #35110Ernest Marcinko
KeymasterHi,
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”.
'carrot' => 'potato carrot',October 10, 2021 at 10:11 am #35112OXYGEN12
ParticipantYou probably didn’t quite understand me correctly. The screenshot example will make everything clear
October 11, 2021 at 1:16 pm #35124Ernest Marcinko
KeymasterFor 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.
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; }October 12, 2021 at 6:51 am #35130OXYGEN12
ParticipantThank you very much! Can you tell me what settings I need to make to display the same search block on my site?
October 12, 2021 at 7:11 am #35133OXYGEN12
ParticipantI am interested in multiple select
October 12, 2021 at 9:33 am #35137Ernest Marcinko
KeymasterSure! For post tags, you can set it here: https://i.imgur.com/Bxqcf1J.png
October 12, 2021 at 10:19 am #35138OXYGEN12
ParticipantAnyway, the plugin doesn’t work the way it does on https://ajaxsearchpro.com/filters-without-search-bar/
Please see the screenshots
October 12, 2021 at 1:25 pm #35140Ernest Marcinko
KeymasterIf you need only the filters without the search bar, then this option will help you with that.
-
AuthorPosts
- You must be logged in to reply to this topic.