Pass outer context variable into query loop #31272
Labels
[Block] Query Loop
Affects the Query Loop Block
Needs Technical Feedback
Needs testing from a developer perspective.
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
I'm making a block that implements a form of post-to-post relationships (in a private repository at the moment) and it needs to be able to access the value of the
postId
context variable outside a query loop when the block is inside the query loop.What is your proposed solution?
I was able to achieve this by having the query loop pass the hard-coded context to
apply_filters
with the outer context as a second argument, and then using this and other filters in my own plugin.Possibly, it could also be done by replacing
WP_Block::render
withrender_block
, becauserender_block
already has a filter that appears to do the same thing.Whichever implementation, there should be a pathway for blocks inside a query loop to be able to access the outer context.
The text was updated successfully, but these errors were encountered: