Like:
a) design company, software company, logistics company
b) Us, UK, Canada
User would look for US design companies by clicking “design company” within first layer and “US” withion second layer.
]]>If you want results that have any one term of several in any combination, it gets more difficult. And/or if some of the search terms lie in different fields, such as custom fields, things get further complicated.
There are a whole bunch of extended search plugins that might meet your needs. It’s worth a little exploration before embarking upon your own coding project.
The general solution in any case is to collect user selections, then either make an Ajax request or POST data to a page that can process such data and return the results. In many cases, a proper WP_Query object can handle the submitted search terms. Your code needs to parse the posted data into proper WP_Query arguments. In some cases, the nature of the search may be beyond the capabilities of WP_Query. You may need to create your own SQL query (using global $wpdb methods) in order to get the desired results.
In composing WP_Query search arguments, keep in mind that the usual relational logic used with multiple terms is AND
. Unless there is a specific OR
option, the logic used will be AND
. If you require OR
logic where no such option is available, you will need to compose your own SQL query.
For example the word “green” can be found with the page of red audi.
For example text: this red audi looks nice on green grass.
I would need to filter specifically via assigned tags (in this case this page would be assigned “audi” in first layer and “red” in second layer.
It sounds so so basic task that i can not imagine any free search plugin not having this. Yet it seems it is not so easy to find. Very strange for such a basic basic filtering need.
Ps: when I say tags I do not necessary mean tags in an actual sense what they are in WP. I mean in general term that I would assigne these to the page/post in order to be filtered by them (as opposed to searching for any word in a text by search)
]]>As a taxonomy, I’d expect extended search plugins to support it, but I’ve no direct experience. Failing that, doing a search with WP_Query using custom taxonomy criteria is fairly straight forward.
]]>
In this example is ice cream shop directory.
On the left you see sidebar where visitor would filter ice cream shops by:
1 layer – home made ; mass produced (ice cream)
2 layer – taste/flavor : vanila, chocolate etc
3 layer – location of the shop.
So lets say yo uar ea visitor and you want to find ice cream shop that sells:
home made ice cream
chocolate
in london
You click all these three tags accordingly at the side bar and get displayed only entries (ice cream shops) that meets this criteria. In this limited example it would be shop “name 2” that would meet the clicked criteria.
Super super basic/crucial navigation for any directory site.
]]>A custom solution could be developed. Most of the work would be in developing the UI. Getting matching posts is relatively simple once you’ve collected the term IDs of the user selections into any array. For example, using tags:
$query = new WP_Query(['tag__in' => $selections,]);
Then run a loop on the $query object to list the matching posts.