I would like to expand Wordpress / WooCommerce search to allow for formulating a query-string that includes custom taxonomies. The default query-string only takes the variable ?s= followed by a search string. I've found various posts, such as this one, that give examples of how to expand this to search custom taxonomies, etc. But it's all done through the same query-string variable (s).

I'd like to pass the exact taxonomy and it's value, or any combination thereof.

For example:

I have custom WooCommerce product taxonomy (set up through Advanced Custom Fields) such as tax1, tax2, tax3.

I have set up a search form that has a drop-down selector for each of these, populated by the values from each custom taxonomy.

I want the user to be able to select an item in one or more of the drop-downs. Upon hitting submit, this should do to a search-results page, that is able to parse the query-string. Which might be something like ?s=&tax1=the-selection&tax2=&tax3=another-selection

The page will then display search results for all products that have tax1 equal to the-selection AND tax3 equal to another-selection.

What would be the recommended way to go about this? Can I achieve this through coding it into functions.php file, or is it best achieved through an existing plug-in?

  • This should just work. You should only need to use whatever the query_var argument of register_taxonomy() is set to. – Jacob Peattie Feb 22 at 12:03
  • @JacobPeattie - Thanks for the comment. This contradicts what I've experienced, and what I've seen online, with regard to many posts and plug-ins, etc., all related to expanding the search functionality to include custom taxonomy and custom fields. Have I missed something? Confused. – omega33 Feb 24 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.