Search by term and taxonomy

Hi!

I’m trying to add a feature to the twenty-twenty theme, to let the user search by inputing keywords, categories and/or tags. The goal is to give the maximum amount of control to the search, allowing for multiple selection of categories/tags and so on.

I’m using a fresh install, changing only the source API (to jsnation2020’s) and menu’s items:
Live: https://frontity-search.vercel.app
Github: https://github.com/arieltonglet/sandbox-frontity-search

By wordpress defaults I would add parameters to the URL, like:
https://frontity-search.vercel.app?cat=6&s=this

My first attempt by just typing this on address bar reflected on the category param appearing on state.source.data.query:

image

But it returned the same 32 items that will pop if I search only by the keyword. So, the “cat” param, although being present, is not reflecting on results.

I’m using jsnation2020.frontity.org as source for this data, and to be sure is wasn’t some error with the query I checked navigating to https://jsnation2020.frontity.org/?cat=6&s=this , which gives the result I desire: only 8 items, filtering both by keyword as by category.

I am a bit lost on how to tackle this. It seems to me that I should be doing some routes customization, but I’m not sure where or how to start that (or even if Frontity allows that)

Thanks in advance!

Hi @ariel.tonglet :wave:

You can indeed search within a category with Frontity! Look at this result: https://frontity-search.vercel.app/category/block/?s=button, it shows all the posts in category Block that also include the word “button”.

I’m not sure how you want your search UI to look like but if you want the user to be able to select from a list of available categories and then search within them, then I hope you see how this could be possible already by fetching using the correct URL :slight_smile:

Hope this helps!