Title: Multiple Input Search
Last modified: May 22, 2023

---

# Multiple Input Search

 *  Resolved [Adam Wilson](https://wordpress.org/support/users/adamalexanderw/)
 * (@adamalexanderw)
 * [3 years ago](https://wordpress.org/support/topic/multiple-input-search-2/)
 * Hi!
 * I’ve got a form with two input fields. A search input and a location input:
 *     ```wp-block-code
       <input type="text" name="s" placeholder="Keyword or trade" />
   
       <input type="text" name="m" placeholder="Location" />
       ```
   
 * If I type whatever I want in the search input it works fine and finds what I 
   want, but the location input doesn’t have any effect.
 * The locations input will ideally check against a custom taxonomy and get the 
   posts from there.
 * Whats the best way to extend the search to use both inputs? Should I just concatenate
   the strings and let Relevanssi figure out the results?
 * Cheers

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [3 years ago](https://wordpress.org/support/topic/multiple-input-search-2/#post-16758544)
 * The `m` parameter means nothing to Relevanssi, and Relevanssi doesn’t look at
   it at all. If you want something to happen, you need to tell Relevanssi what 
   to do with that.
 * The easy Relevanssi solution would be to discard the whole input field and use
   only one input field. Relevanssi will handle that just fine, and it’s also the
   easiest thing for users.
 * You can also concatenate the `m` parameter to the `s` parameter, which is effectively
   the same.
 * If you want more control, you can convert the `m` parameter to a `tax_query`,
   but that leads to trouble if the user does not enter a `s` parameter.
 * I’d go with the one-field strategy; that’s probably the most effective.
 *  Thread Starter [Adam Wilson](https://wordpress.org/support/users/adamalexanderw/)
 * (@adamalexanderw)
 * [3 years ago](https://wordpress.org/support/topic/multiple-input-search-2/#post-16760346)
 * Thanks Mikko.
 * I understand the `m` parameter means nothing to Relevanssi, I’m basically asking
   what is the recommended way to handle it.
 * I think saying one field is the best thing for users is a fairly broad statement.
   There could be a thousand use cases where someone may want multiple inputs.
 * Would it be completely out of the plugins scope to use two inputs for the search?
 * I will see how it works with the concatenation. Might be worth adding some documentation
   to address this point as I couldn’t find anything.
 * Thanks for all your work on the plugin so far.
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [3 years ago](https://wordpress.org/support/topic/multiple-input-search-2/#post-16761005)
 * Well, I outlined the approaches you can take:
    1. Discard the field, and just use one input field. This loses precision, but is
       easy to use and understand for users and is the easiest to set up.
    2. Use both fields, but combine their contents in a filter function so that there’s
       two fields in the UI, but only one field in practise. Users probably won’t notice
       anything, and this is easy to set up.
    3. Use both fields and convert the value in the `m` field to a taxonomy query. 
       This has the best precision, but takes the most effort to set up. If you want
       to use two input fields, I would recommend this option, as otherwise it’s just
       better to use one input field.
    4. Bonus option for Relevanssi Premium: you can use the `m` input field as a Relevanssi
       search term field, but make it only target that one specific taxonomy. This 
       is a pretty neat option, but only available in Relevanssi Premium.
 * Here’s how you can do the concatenation:
 *     ```wp-block-code
       add_filter( 'relevanssi_modify_wp_query', function( $query ) {
         $query->query_vars['s'] .= ' ' . $query->query_vars['m'];
         return $query;
       } );
       ```
   
 *  Thread Starter [Adam Wilson](https://wordpress.org/support/users/adamalexanderw/)
 * (@adamalexanderw)
 * [3 years ago](https://wordpress.org/support/topic/multiple-input-search-2/#post-16761469)
 * Cheers.
 * I tried the concatenation and it didn’t give me quite what I expected.
 * I’m happy to give Relevanssi Premium a go and see how that works.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Multiple Input Search’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

## Tags

 * [input](https://wordpress.org/support/topic-tag/input/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 4 replies
 * 2 participants
 * Last reply from: [Adam Wilson](https://wordpress.org/support/users/adamalexanderw/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/multiple-input-search-2/#post-16761469)
 * Status: resolved