WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.51k stars 4.2k forks source link

Page List Block optionally lists subpages only #48149

Open ClarusDignus opened 1 year ago

ClarusDignus commented 1 year ago

What problem does this address?

The core Page List Block displays all top-level pages. In same cases, users may need to list only the subpages of the current page or an arbitrary page.

It's my argument that users require/expect this functionality in that the popular plugin of the same name, Page-list, provides such functionality. This plugin also provides the option to list all top-level pages, as the core Page-List Block currently does. Listing top-level pages is a one-dimensional solution, whereas the user's requirements for listing pages are multi-dimensional.

What is your proposed solution?

Add settings to the core Page List Block in the form of a dropdown in which "All Pages" and "Subpages of Current" are the first two options and the rest of the options are parent pages to choose from, like the Parent Page field under Page Attributes in page settings.

Parent Page Field

The following approach was recommended in a topic in the WordPress Requests and Feedback forum:

It would be possible to custom code a solution by altering the page query the block makes. Setting the “post_parent” query var through the “pre_get_posts” action hook will force the query to only return child pages. The trick will be in distinguishing a specific page block query from all others. There is often some unique combination of query vars that could be checked as confirmation.

Antera commented 7 months ago

Hello, Having a way to display child pages of the current page or selected parent page is really needed in WordPress It's so hard to find a solution to do this, even pages are the foundations of WordPress

With an option to display those child pages as a grid

sirjonathan commented 6 months ago

Adding a +1 to this.

I'd also love to see "Sibling pages of current" option.

PierreAmmeloot commented 2 months ago

+1 I have the same need.

dysko-bridge-sa commented 2 months ago

Adding a +1 to this.

I'd also love to see "Sibling pages of current" option.