Matt Stone
Matt Stone

Reputation: 3900

Algolia Wordpress plugin without Instantsearch.js - filtering results by taxonomy

The Algolia Wordpress plugin (https://community.algolia.com/wordpress/) replaces the standard Wordpress search.

I've selected the Use Algolia in the backend setting instead of Use Algolia with Instantsearch.js, because I need complete control over the UI.

Algolia setting in Wordpress

This option states that it does not support filtering and displaying instant search results. However, I'm assuming this is referring to Instantsearch.js and there is still a way to filter the API query manually.

I need to either:

  1. Filter the Algolia API search results by taxonomy, likely with facets. Can I customise the query that is sent to the Algolia API to include facet filtering?
  2. If that's not possible, is there a plugin filter that would allow me to filter the results (and adjust the global WP_Query) after the API query has completed?

Thanks in advance.

Upvotes: 0

Views: 713

Answers (1)

rayrutjes
rayrutjes

Reputation: 798

There is a filter hook that can be used to adjust the parameters used for the call to Algolia: algolia_search_params.

This filter is called right before doing the search operation: https://github.com/algolia/algoliasearch-wordpress/blob/master/includes/class-algolia-search.php#L59

By using that filter you can provide any valid Algolia search parameter.

Upvotes: 1

Related Questions