10up / ElasticPress

A fast and flexible search and query engine for WordPress.
https://elasticpress.io
GNU General Public License v2.0
1.23k stars 312 forks source link

How to show only certain categories for a filter? #3920

Closed rstrah closed 2 months ago

rstrah commented 2 months ago

Describe your question

You can select filters on the Instant Results page. I select a filter by the news category, but there are too many categories (there are even some that have not been filled in for a long time). How can I make it so that not the entire array of categories is displayed, but only those that I want?

Code of Conduct

felipeelia commented 2 months ago

The plugin does not provide a direct way to change the list of terms retrieved by Elasticsearch. If there are terms that are not relevant to your search experience at all, the easiest way would be for you to simply avoid indexing them. For that, you can use the ep_post_sync_args_post_prepare_meta filter to change the post object -- you'll need to tweak the terms attribute of that object.