Child Pages on Parent Page and Sibling Pages on Child Pages

A user asks:

I have a parent page with 10 child pages. I will display a sidebar where I display links to the child pages. This sidebar has to show on the masterpage but also on the childpages.

Is there a way to do this in the query builder?

This Pro tutorial for Bricks users shows how we can define a custom function that returns an array of post IDs of the current post's (can be a Page or any hierarchical post type) children if it has children or that of the sibling posts + the current post if it has a parent - to be used in a single post template.

Given

after implementing this tutorial,

on a parent Page:

on a child Page:

on other Pages:

Step 1

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 525 Bricks code tutorials with BricksLabs Pro