Setting a Bricks template for Parent pages

This Pro tutorial shows how bricks/active_templates filter can be used to programmatically assign a Bricks template to all singular pages (of any post type) that are parents i.e., have other child pages (of the same post type).

The code snippet can also be modified to only apply to parent posts of a specific post type, if needed.

Add the following in child theme's functions.php or a code snippets plugin:

Step 1

Create a Bricks template of "single" type named say "Parent page".

Edit it and add your desired elements inside.

Go to the list of templates and note the template ID.

Step 2

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF Relationship Select Filter in Bricks

ACF Relationship Select Filter in Bricks

In the BricksLabs Facebook group, a user asks: I'm learning about ACF relationships and attempting to output a list of posts on any given page,…
Categories:
How to Exclude Elements from Bricks Editor

How to Exclude Elements from Bricks Editor

Bricks has a handy bricks/builder/elements filter using which the available elements that show up after clicking + (or ⌃/⌘ + ⇧ + E) in the…
Categories:
Tags:
Pro
Current Post Has Parent – Conditional Single Template

Current Post Has Parent – Conditional Single Template

How to apply one of two Bricks templates to posts depending on whether that post has a parent or not.