fix/4193: Fix meta facet counts for late-rendered facet-meta blocks#4284
Open
Sidsector9 wants to merge 4 commits intodevelopfrom
Open
fix/4193: Fix meta facet counts for late-rendered facet-meta blocks#4284Sidsector9 wants to merge 4 commits intodevelopfrom
Sidsector9 wants to merge 4 commits intodevelopfrom
Conversation
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
What was the issue?
The meta facet aggregations were built during the main facetable query, based on facet fields discovered early. When
elasticpress/facet-metais rendered later at runtime (for example viado_blocks()), the main query has already completed. In that case, the requested meta field is missing from the original aggregation request, so that facet receives no counts and terms render as disabled/empty.How does this fix work?
This PR adds a runtime-safe fallback for meta facet aggregations:
get_facet_aggregation_for_field()in the meta facet type.Closes #4193
How to test the Change
Replace
hero_captionfrom the following with a meta value that is relevant to your site, and add it to your functions.php file:On
develop, it will display the the list, but the counts will be 0, making the list items not clickable. Switch to the fix branch and observe that it displays the count, and the items are clickable.Changelog Entry
Credits
Props @burhandodhy @Sidsector9
Checklist: