[54461]: Query block toggle - get all descendants of current page#69053
[54461]: Query block toggle - get all descendants of current page#69053PaulREnglish wants to merge 7 commits into
Conversation
To get descendants of a particular page, we first need to fetch all pages so we can pass them through get_page_children()
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @PaulREnglish! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Here's a demo of how it currently works. Still a WIP but any feedback would be appreciated: Screen.Capture.on.2025-02-05.at.15-41-44.mp4 |
Hi 👋! Thanks for the question :D |
|
Does anyone have any thoughts regarding the approach I've taken codewise with regards to getting all descendants? An alternative approach I did consider but haven't used would be to loop over the page hierarchy and execute a different sql query for every depth we need to fetch children from. (So one sql query would fetch the direct children of the parent, a second sql query would fetch the children of those children, etc, etc). |
|
After some discussion in Slack, I'm going to try to add the See ticket here: https://core.trac.wordpress.org/ticket/62953#ticket |
|
Thanks again for working on this, @PaulREnglish! Let's continue the technical discussion around I'm going to remove this enhancement request from the WP 6.8 project board. |
My pleasure!
Sounds good. |
|
@PaulREnglish raised this PR and the related Trac ticket in today's Dev Chat. While I agree that adding core support for querying all ancestors will require some discussion that will cause this to miss the 6.8 milestone, I think it might be worth reducing the scope of this PR to only address the original issue, which is to set the query block to show only direct children of the current page. I think that could be done with existing functionality and then iterated on in future versions of GB that would be included in 6.9. |
The usage of filters was a rather hacky implementation as the ancestor query prop ought to be implemented in WordPress Core rather than Gutenberg.
0016873 to
ab0ab27
Compare
Thanks very much for your input! I've reverted the ancestor/show all descendants toggle leaving behind only the "Set parent as current page" toggle which should hopefully address the original issue. I'll take some screenshots of how it works then I can mark this PR as ready to review. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |


What?
Resolves: #54461
Adds a toggle to set the current page as the parent page.
Why?
See #54461 (comment).
How?
Switching the 'Set parent as current page' toggle to the 'on' position will set the
Parentsquery to an array containing only the current page's id. Switching this toggle off will empty this array.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast