Fix post exclusion when post__in is set via Advanced Query Loop#8
Merged
roborourke merged 8 commits intomainfrom Jan 27, 2026
Merged
Fix post exclusion when post__in is set via Advanced Query Loop#8roborourke merged 8 commits intomainfrom
post__in is set via Advanced Query Loop#8roborourke merged 8 commits intomainfrom
Conversation
When a query loop uses post__in (e.g., via Advanced Query Loop plugin), WordPress ignores post__not_in. This fix ensures exclusions work correctly by also filtering the post__in array to remove already displayed post IDs. - Add exclude_posts_from_query() helper that handles both post__not_in and post__in - Refactor modify_query_from_block_attrs() to use the new helper - Add Advanced Query Loop plugin to test environment - Add E2E test for post__in exclusion behavior Fixes #7 https://claude.ai/code/session_01GpFyKZGFSn2rTG4WmkumeU
post__in is set via Advanced Query Loop
Playwright test resultsDetails
|
…ed helper functions
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.
Summary
This PR fixes a bug where the "Exclude Displayed Posts" feature didn't work correctly when a query loop used the
post__inparameter (commonly set by the Advanced Query Loop plugin). WordPress ignorespost__not_inwhenpost__inis present, so we now filter thepost__inarray directly to exclude already-displayed posts.Key Changes
New
exclude_posts_from_query()function: Handles exclusions intelligently by:post__inwhen it's set (since it takes precedence)post__not_infor queries withoutpost__inRefactored exclusion logic: Updated both
excludeDisplayedandexcludeDisplayedForCurrentLoopcode paths to use the new helper function, eliminating code duplicationAdded comprehensive E2E tests: Two new test cases verify:
post__inparameterUpdated dev environment: Added Advanced Query Loop plugin to
.wp-env.jsonfor testingImplementation Details
The fix addresses a WordPress core behavior where
post__intakes precedence overpost__not_in. When Advanced Query Loop sets specific post IDs viapost__in, our exclusion logic now:post__inarraypost__not_infor fallback behavior in other query scenarios