A user asked:
Hi there, I have a Toggle added to the pages using ACF. I have a pages where I Loop all the pages that have that toggle ON. Easy.
Some of those pages have children. I want to create another page that loops all those children. So, I need all the children of pages that toggle on.
Any idea how to do it?
This Pro tutorial for Bricks users shows how we can
- list all the Pages as an unordered list with indentation
- output all the Pages that have the value of a custom field of true/false type set to true i.e., featured Pages
- output all featured Pages that have at least 1 child i.e., parent Pages in ascending order of titles
- output all child Pages of the featured parent Pages in ascending order of titles
Step 1
To list all the Pages in a hierarchical manner, add this in a Code element:
<?php
wp_list_pages(
[
'title_li' => '',
]
);
?>
Step 2
To output all Pages that have a true (1) or false (0) type of custom field (featured
in this example) equal to 1, set up a query loop like this:
Step 3
To output all parent featured Pages ordered by titles in ascending order, enable query loop on a block.
Post type: Pages
Enable 'Query editor (PHP)'.
Paste:
This is a BricksLabs Pro tutorial.
For full access login below or create your BricksLabs Pro account