• Resolved specotech

    (@specotech)


    When searching for products on my site I would like results that include the searched term with extra characters. For example our product is called “N8NRE” but sometimes visitors will type in “N8NRE4TB” because that includes the terabyte size of our product but gives no results. Is there a way without adding hundreds of synonyms for products of ours to be searched with additional terrabyte sizes? So “N8NRE4TB”, “N8NRE6TB”, “N8NRE12TB”, etc. to always direct to “N8NRE” instead of giving no results? Thanks!

    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

    (@msaari)

    That direction is much harder to do.

    One approach is to filter the search queries and simply remove any “xxTB” from the end. Add this to your theme functions.php:

    add_filter( 'relevanssi_modify_wp_query', 'rlv_tb_filter' );
    function rlv_tb_filter( $query ) {
      $query->query_vars['s'] = preg_replace( '/\d+tb$/i', '', $query->query_vars['s'] );
      return $query;
    }
    Thread Starter specotech

    (@specotech)

    Thank you so much. That worked!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Don’t get results when the product name is searched with additional characters?’ is closed to new replies.