feat: exclude current post from query#155
Open
laravdiemen wants to merge 1 commit into
Open
Conversation
|
Coverage report for commit: 94a470c Summary - Lines: 29.43% | Methods: 58.18%
🤖 comment via lucassabreu/comment-coverage-clover |
||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the query block so it excludes the currently viewed post from automatic query results by default, while allowing projects to opt out via a PHP filter.
Changes:
- Adds
yard_query_block_exclude_current_postfilter around the default exclusion behavior. - Adds logic to detect the current post ID and append an
ID != currentconstraint. - Skips exclusion for manual selections and sticky-post cases.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2e8de36 to
94a470c
Compare
mvdhoek1
approved these changes
May 27, 2026
| private function currentPostId(): int | ||
| { | ||
| if (function_exists('get_the_ID') && $id = get_the_ID()) { | ||
| return $id; |
| } | ||
|
|
||
| if (function_exists('get_queried_object_id')) { | ||
| return get_queried_object_id(); |
There was a problem hiding this comment.
Voor de zekerheid misschien:
return (int) get_queried_object_id();
| * | ||
| * This applies when the query is not using a manual selection and the current post is not the configured sticky post. | ||
| * | ||
| * @param bool $excludeCurrentPost Whether to exclude the current post from the query results. Default true. |
There was a problem hiding this comment.
Ik weet niet of ik de @param en @return echt zinvol vindt en tussen de 2e eerste regels staan wat mij betreft een enter teveel. 🐜
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.
Het query blok toont nu ook de huidige pagina waarop je zit. Dat is onnodig want als je er dan op klikt, dan komt je weer precies bij dezelfde pagina uit. Ik heb er een apply_filters omheen gezet zodat je het eventueel via je thema wel kan overschrijven.