WebDevStudios / algolia-snippet-library

Snippet library for working with WP Search with Algolia and Algolia.com
MIT License
4 stars 0 forks source link

Using algolia_search_params as a pre_get_posts filter for the Algolia query #1

Open tw2113 opened 1 year ago

tw2113 commented 1 year ago

Making use of algolia_search_params allows for amending parameters used in the query for Algolia's search.

With it, you can amend the array of parameters, as documented at https://www.algolia.com/doc/api-reference/search-api-parameters/

Most specifically, you would want to make use of the filters parameter, which is documented at https://www.algolia.com/doc/api-reference/api-parameters/filters/

Make sure to note this detail:

You must declare for each attribute you use as a filter in attributesForFaceting, except for _tags, which are automatically considered as attributesForFaceting.

tw2113 commented 1 year ago

I feel this is validated from the original devs, via https://stackoverflow.com/questions/45704152/algolia-wordpress-plugin-without-instantsearch-js-filtering-results-by-taxonom/45752228#45752228

and a cross-posted item at

https://discourse.algolia.com/t/algolia-wordpress-plugin-without-instantsearch-js-filtering-results-by-taxonomy/2367