yezzzParticipant3 years, 5 months ago #12387
I’ve seen websites that have a dropdown next to their search suggestions that act as a filter.
Nnote the bug: on the homepage selecting “cameras” from the dropdown then searching something will still include suggestions for phones…
Another example with 2 dropdowns (the left one is a bit pointless imho):
The rewise theme, when visiting a category page, automatically sets a matching select value. The following commercial site has a UI twist to that: they preselect with a removable filter, and they also put in a custom placeholder in the input:
I’d be interested to have such feature with a select filter or other UI element, with the ability to specificy what’s used for filtering (eg custom taxonomy terms).
Or maybe this can be done via the ajax autocomplete action and a filtering hook?wpsolrKeymaster3 years, 5 months ago #12390
1) I don’t think there is a universal way to filter the suggestions with a UI element defining a specific term.
To do that, we should be able to define a way to collect the term value, from the UI element. It could be done with a jQuery selector. But it depends on the UI itself. For instance, the UI could be a simple html select. Or a js select2 select. Or a js chosen select.
And instead of a term, it could be a post type (‘Product/Post/Page’), or a product attribute (‘blue/red/yellow’ color), or a location, or any custom field.
2) The other way to do it is by building specific extensions for some popular themes.Those themes already collects the UI element value, and pass it to their Ajax suggestion call. Now, it’s just a question to use hooks in the backend to get the element value and add a filter to the Elasticsearch/Solr query.
WPSOLR has done just that for Listify and Jobify. But it depends on the theme’s hooks. Sometimes, it simply cannot be done.
You must be logged in to reply to this topic.