I need to find some way to allow front-end filtering of the results of a query loop block. The ideal way to do this would be to use URL parameters to modify the query loop results, similar to the search block.
Is there an easy way to do this with a variation on the Query Loop block? Or am I going to have to make something entirely custom for this purpose? I’d love to use as much out-of-the-box code as possible.
2
Answers
This was addressed on wordpress.stackexchange.com:
Source:
https://wordpress.stackexchange.com/questions/407888/how-to-filter-query-loop-block-with-a-search-string-from-the-query-parameters
You can extend the Query Loop block by creating a variation that specifies query parameters. Below is a simple block variation for the setting search parameter of the Query Loop:
JS
You can then add your Query block variation to any post/page/template.
For the front-end, if you are editing the Search template for your theme, I would use the Button block to provide links for changing the search parameters, no block variation required, eg:
Site Editor > Templates > Search
Depending on your end goal, the documentation on Extending the Query may be useful as well.