• Resolved jsmilesit

    (@jsmilesit)


    Its there way to exclude a word from the search query in Algolia by adding code in functions.php

    I tried adding this code in functions.php and I couldn’t get it to work.

    add_filter(‘algolia_search_params’, ‘exclude_specific_phrases_from_search’, 10, 2);

    function exclude_specific_phrases_from_search($params, $query) {
    $excluded_phrases = [‘bird guard glass’, ‘bird glass’];
    foreach ($excluded_phrases as $phrase) { $query .= ‘ -“‘.$phrase.'”‘;
    }
    $params[‘query’] = $query;
    return $params;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.