Wordpress search results is definately not the best indexing and search function we have seen.. If adding multiple tag variables in the search in order to get a more precise result work?

For example:

Default search query: www.example.com/?s=kidsbook

What if we spiced it up a bit adding: in the search some more tags that the results must have (for example female author and bestseller). So that only post results of kidsbook AND from those results only the best sellers of female authors.

would the bellow example work?


Would the search accept both tags?

Last question would this type of search cause a much greater load on the server?

Thanks for your answers.

1 Answer 1


Add a new input to the form, the name is key, you can easily access query vars that match a paremeter supporter by WP_Query using the function get_query_var.

For example, you could try to generate an URL like this:


And with get_query_var(tag), you get the values, and the you create a custom WP_Query using that parameters.

$query = new WP_Query(
    's' => get_query_var('s'), 
    'tag' => get_query_var('tag')
) );

One thing you have to take into account is that can't have the same parameter twice in the URL, well, you can, but you can't use the get_query_var function to get the value.

You can use jQuery to get the selected options from a select element with the multipleattribute, and pass the selection to an input with the name "tag", there are other workarounds for this.

The query wont affect performance that much.

I hope this gives you and idea of what to do.

  • Thank you for your answer Tomas, sadly I cant do that as I need to have it in a multiple selection. If I just add this: www.example.com/?s=kidsbook&tag=femaleauthor&tag=bestseller would it be executed correctly by the server/wp engine? Commented Sep 27, 2014 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.