In the BricksLabs Facebook group, a user asks:
Wonder:
Is it possible to automatically select a single post template depending on the page from which the post is accessed?
Example: My post "Opening ceremony" appears on the page "News" and on the page "Events". If the user opens this post from the news page, template 1 should be selected automatically. If the user opens this post from the Events page, Template 2 should be selected automatically.
This Pro tutorial shows how bricks/active_templates filter can be used to show single posts in different Bricks templates for different pages based on the page URLs.
Step 1
Create three Bricks templates:
- one for when the user visits any post from the /news page
- another for when the user visits any post from the /events page
- another default template
For the default template, make sure you set the template condition.
The other two should not have a template condition set.
Step 2
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