feat/3954: Add filters to exclude post types and taxonomy terms from Instant Results - #4290
Merged
Conversation
Member
|
We will need tests for this one, @Sidsector9. |
Member
Author
|
@felipeelia the tests have been added 👍 |
felipeelia
requested changes
Aug 6, 2026
felipeelia
left a comment
Member
There was a problem hiding this comment.
@Sidsector9 We will need to replace all the 5.4.0 with 5.3.4. In addition to that, can you please change get_excluded_post_types and get_excluded_term_ids returns, so we always make sure they are sending the correct types back to the caller?
Something like array_filter( array_map( 'absint', (array) apply_filters( 'ep_instant_results_excluded_term_ids', [] ) ) );, but properly written.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Change
ep_instant_results_excluded_post_typesfilter to exclude post types and related posts from Instant Results.ep_instant_results_excluded_term_idsfilter to exclude taxonomy terms from Instant Results facets.Post Type Exclusion (
ep_instant_results_excluded_post_types)Excluded post types are removed from both the Post Type facet and the search template itself. This means content of that type will not appear in Instant Results at all.
The search template is regenerated when Instant Results settings are saved, when the weighting configuration is saved, and after a full sync. So after changing this filter, save either settings screen, run a sync, or run
wp elasticpress put-search-template, otherwise the old template stays in use.Term Exclusion (
ep_instant_results_excluded_term_ids)Excluded terms are hidden from every taxonomy facet (Category, Tag, etc.) but posts associated with those terms still appear in search results. This is intentional, a post can belong to multiple terms, so excluding a term from the facet should not remove posts that also match through other, non-excluded terms.
Closes #3954
Changelog Entry
Credits
Props @feliciaoctocog, @Sidsector9
Checklist: