I'm trying to understand how Wordpress search works. I haven't found much info on the Codex. Arguably, search is not the best WP feature. Even Wordpress.org uses Google Search.

I would like to make a custom search form to allow people search using my custom taxonomies and custom meta fields.

I'd imagine the search query would work exactly as a normal WP query, therefore a tax query and a meta query should be possible.

But how to pass the user submitted form data to a search query?

Is it possible to pass form variables to the /?s= search string in the address bar? that would make things easier...

I know there are many plugins around. Some of them quite complex. But I don't mind learning my own way and eventually the few I tried would require some adaptation for my theme (which uses almost ten different post types and a bunch of custom taxonomies, plus loads of custom fields handled by Advanced Custom Fields plugin).

Is there any detailed article that goes in depth regarding this matter?


I just came up with an idea, to make a form in one page, then pass the input fields variables with $GET to another page template which holds a custom WP_Query and with some IFs and ELSEs perform a custom query... Eventually I will post an answer with the code when I'm done. This is close to what I was asking, although I wanted to know if it was possible without creating a new template with a new query, oh well...

1 Answer 1


I had the same question a couple of weeks ago. Here's what I did to make it work for me.

How Do I Use WP_Query to Run This Database Query as Search Result?

If you'll read through my answer that I posted for reference's sake, you'll see that I ended up adding a filter add_filter('post_request','your_function_name'); which basically allowed me to completely rewrite the mysql query that was returning results from the database based off of additional parameters that I was passing through the query string in the URL.

  • that's interesting Brent, I will definitely keep your post as a reference
    – unfulvio
    Sep 10, 2012 at 7:08

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.