Tag search option

This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 2 years, 6 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #35104
    OXYGEN12
    OXYGEN12
    Participant

    Hello. What settings do I need to make to get this tag search option?

    https://ajaxsearchpro.com/filters-without-search-bar/

    #35105
    OXYGEN12
    OXYGEN12
    Participant

    I 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?

    #35110
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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',

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #35112
    OXYGEN12
    OXYGEN12
    Participant

    You probably didn’t quite understand me correctly. The screenshot example will make everything clear

    Attachments:
    You must be logged in to view attached files.
    #35124
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    For 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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #35130
    OXYGEN12
    OXYGEN12
    Participant

    Thank 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.
    #35133
    OXYGEN12
    OXYGEN12
    Participant

    I am interested in multiple select

    #35137
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Sure! 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 :)


    #35138
    OXYGEN12
    OXYGEN12
    Participant

    Anyway, 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.
    #35140
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    If 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 :)


Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.