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

    (@msaari)

    Yes, but it takes some coding. You need a filter on relevanssi_fuzzy_query that modifies the query based on the dropdown selection.

    add_filter( 'relevanssi_fuzzy_query', 'rlv_dropdown' );
    function rlv_dropdown( $query ) {
      if ( isset( $_REQUEST['search_type'] ) && 'startswith' === $_REQUEST['search_type'] ) {
        return "(relevanssi.term LIKE '#term#%') ";
      }
      if ( isset( $_REQUEST['search_type'] ) && 'equals' === $_REQUEST['search_type'] ) {
        return "(relevanssi.term LIKE '#term#') ";
      }
      if ( isset( $_REQUEST['search_type'] ) && 'contains' === $_REQUEST['search_type'] ) {
        return "(relevanssi.term LIKE '%#term#%') ";
      }
    }

    That should do the trick, with a dropdown like this:

    <select name="search_type">
      <option value="startswith">Starts with</option>
      <option value="equals">Equals</option>
      <option value="contains">Contains</option>
    </select>
Viewing 1 replies (of 1 total)

The topic ‘drop-down list’ is closed to new replies.