最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Search custom taxonomy via query-string?

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论