Support » Plugin: Relevanssi - A Better Search » Using a function specific to only one page’s search field

  • Resolved nickmomentum


    We are using Relevanssi to search for Woocommerce products as well as zipcodes for Canada and the US. To be able to make search work for Canadian zipcodes which are normally: “xxx xxx” we had to add a function to make the search more literal:
    if (is_page(apply_filters(‘wpml_object_id’,65))){
    add_filter(‘relevanssi_search_filters’, ‘add_double_quotes’);
    function add_double_quotes($args) {
    $args[‘q’] = ‘”‘ . $args[‘q’] . ‘”‘;
    return $args;
    However, this function has limited the search ability of the products (causing the search to be too specific) and will not work on only one page. Is it at all possible to have two different search parameters using this plugin. For instance, one search bar would use that function, and another would not? What do you recommend in this instance?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari


    The thing is, when Relevanssi runs and the filter should be activated, you’re not on page 65 anymore.

    However, there’s an easier way to do this. All you need to do is to add the sentence parameter to your search form with the value 1. If you use the Relevanssi shortcode, use

    [searchform post_types="representative" sentence="1"]

    If you’re doing this manually, add this to your form:

    <input type="hidden" name="sentence" value="1" />

    Awesome, this worked!

    Thank You!

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