Closed Pulsar-X closed 11 months ago
This is really nice addition and thanks for putting it together!
Would it be possible for you to split these out into two PRs; one for the current post exclude and the other for excluding a list of posts?
I'd love to land excluding the current post pretty quickly but I'd like to think about the list of posts a little as it can be a pretty expensive query.
Great work!
@ryanwelcher I apologize for taking so long to fix this up.
I have removed everything that concerns excluding a list of posts, leaving only the functionality to exclude the current post with a toggle switch.
I'll open another PR soon to add the missing functionality back in.
Please let me know if I should change anything else.
This is a great addition! Thanks for splitting it out. I am 99% sure I'll merge the other part but just wanted to think about it before as it could mean an expensive query.
This PR implements two things:
This works across multiple Post Types.
To accomplish this, two new attributes were introduced:
exclude_posts
: An array of post IDs that should be excludedexclude_current
: The current post ID, if it should be excluded, or 0, if not.In an initial implementation,
exclude_current
was a boolean. I unfortunately found no way to access the current post ID in the context of therest_post_query
filter for the preview in the block editor (query-loop.php, ln. 238). Now the current ID just gets passed as an attribute.If you have any idea how to implement this without passing the current post ID, please feel free to modify my solution.
I am quite new to WordPress development, so if I have committed any blunders, please point them out.
Closes #3