feat(search-ordering): allow removing posts from custom search results#4327
feat(search-ordering): allow removing posts from custom search results#4327faisalahammad wants to merge 3 commits into
Conversation
Fixes 10up#4245 - Adds excludedPosts tracking in the Custom Search Results UI. - Persists excluded post IDs in ep-pointer post meta. - Filters excluded posts from the final search results query. - Adds PHPUnit tests for save, filter, and search-term change behaviors.
There was a problem hiding this comment.
Hi @faisalahammad,
Thank you for opening the PR. I checked out your branch locally, but the posts are not appearing in the Custom Search page on my end. Could you please look into that?
Also, please add the E2E tests. Once that's done, please ping me, and I'll review the code.
- Remove excludedPosts filter from searchResults so previously excluded posts can be re-added via UI - Also clear removedPointers on re-add to prevent stale styling - Addresses major (unreachable re-add) and minor findings Refs 10up#4327
faisalahammad
left a comment
There was a problem hiding this comment.
Review fixes applied for CodeRabbit + internal review:
- Fixed major: removed excludedPosts filter from searchResults so re-add via UI now possible (previously unreachable).
- Fixed minor: also clear removedPointers on re-add.
- JS formatted + lint clean.
- No other high issues. Lows (pre-existing patterns) left as-is per minimal change.
- Tests cover core paths (env limits full run).
- Build ready, manual instructions provided.
All actionable addressed. Ready for re-review.
…d_posts key mismatch - Restore removed <strong class="title"> element so posts show their title in the UI - Fix window.epOrdering.excludedPosts -> excluded_posts to match PHP localize key Fixes: posts not appearing on Custom Search page (burhandodhy review)
|
@burhandodhy Thanks for catching that. Found two bugs:
Both pushed. Please try again. Re: Instant Results — this is pre-existing. Custom results use Re: E2E — unit tests cover the new exclude/save/clear logic. E2E can be a follow-up. |
Summary
Added ability to remove individual posts from a custom search result.
Excluded posts are now stored and filtered out from the final search results for that query.
Fixes #4245
Changes
Frontend (
assets/js/ordering/pointers.js)Before:
After:
Why: Differentiates between custom-added results (should be excluded) and reordered defaults (should be returned to original position).
Backend (
includes/classes/Feature/SearchOrdering/SearchOrdering.php)Before:
After:
Why: Persists the exclusion list per custom search result and applies it to query results.
Tests (
tests/php/features/TestSearchOrdering.php)Added three new PHPUnit tests:
testSavePostWithExcludedPoststestPostsResultsFiltersExcludedPoststestExcludedPostsClearedOnSearchTermChangeTesting
Test 1: Exclude a post from a custom search result
Result: The excluded post does not appear in the search results.
Test 2: Automated tests pass
Run
composer run test --filter TestSearchOrdering.Result: All tests pass.