Right now it’s not currently possible to create a truly dynamic/scalable partial template in Bricks.
For example, let’s say you have a “Services” CPT that controls all your service pages. You want each Service page to have the same hero section layout, but then you want to customize the rest of the page in Bricks with the builder.
In Oxygen, you can create a template assigned to Services pages and add your hero layout to that template. You can then tell the template to dynamically inherit the page content for the rest of the template (meaning it will inherit whatever you build inside Bricks for each service page). They call this an “inner content” element, but really it’s just dynamically pulling whatever page content was created in the builder for that page/post.
In Bricks, you have to save the hero as a template section and then open up each service page individually and add a template element that references that template section. This isn’t nearly as scalable/maintainable because it requires manually editing every single services page. And if you ever want to remove the hero heading from all services pages, you have to edit each one individually again and remove it.
You won’t believe it! I was coming to this forum FOR THE FIRST TIME to ask exactly about this.
a. You solved my question (I needed to add the template on the page for it to show)
b. This method doesn’t make so much sense, because as it is right now the template works as a “reusable section” and not so much as a template (and as you point out, it is far from scalable).
Exactly what i am waiting / hoping for. Really wondering if this will ever happen.
And yes this a very important when it comes to more complex pages.
Let’s see what they say. Really hoping for a better, more granular approach on templates.
Create a services template i.e. with the hero section, sidebar etc. Add the post content element where you want the dynamic content from the services pages created in Bricks will be displayed and set it to output bricks content not WP content (inside the post content element).
Assign this to the services pages via conditions.
Create the pages in bricks (minus information held inside the template i.e. the hero section).
If you are using pages (for your service pages), you will need a way to target them in conditions. You can do this by adding tag support to pages and assigning a tag i.e. service
Code needed (not needed if saving your CPT is outputted with post capability):
// // add tag support to pages
function tags_support_all() {
register_taxonomy_for_object_type('post_tag', 'page', 'post_type_faq');
}
// ensure all tags are included in queries
function tags_support_query($wp_query) {
if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');
}
// tag hooks
add_action('init', 'tags_support_all');
add_action('pre_get_posts', 'tags_support_query');
You’re misunderstanding, Michael is saying what is being requested here is already possible in Bricks. It’s just different to Oxygen.
Instead of the inner content element, you instead use the ‘post content’ element and set the data source to ‘bricks’. If you do that for a services CPT, then you can create your hero section in your services template, and then create all service page using Bricks for the page content. They’ll inherit the service template hero section. You can then change the hero section in just one place, in the template, and all service pages will change.
If he does what he did in his video, then the solution is 100% super dooper easy, super user-friendly, and can be used on super duper complex pages, and guess what…WITH NO CODE.
Safe warning…if you watch the video close your eyes between 48 mins and 53 mins because he used code
I flagged this post for deleting about 10 minutes after I created it. Unfortunately we can’t delete our own threads.
For some reason my brain was thinking the post content element was only for Gutenberg content. I totally didn’t realize it came with a dropdown for selecting Bricks content as an option. Once I saw that I tried to delete the feature request. Alas … can’t delete it
Alright, I tried what I understood from this thread, but I couldn’t make it work. Let’s see if anybody can give me a hand on this.
Imagine that I want to create a floating contact section that goes on every page. I create a template as “section”, create the section on the template, add the condition to apply to the entire website. Then add a “post content” on the template, and set it to “Bricks”.
Still, I can see the floating section on the homepage, unless I add it manually from “templates”.
the template type would need to be ‘single’, not ‘section’.
it will only apply on the homepage if you don’t have a front page template applied there. Otherwise, the front page template would override the single template that you created.
if you instead build your home page in Bricks, by editing the page in Bricks (not using a front page template) then you’ll see the section as inherited from the global template that you made.
It’s not as flexible as Oxygen’s, where you can go deep into nested templates or add priorities (it’s a flatter structure). But you can have a page or post made in Bricks, which is inheriting a template. (by adding the post content element in that template)
So David. As I promised, I write again to let you know that I finally was able to make it work as expected it is not complicated at all, but yes confusing (at least coming from Oxygen). But the important thing is that it works, that you helped me immensely , that now I understand the right way to do this, and that I will remake the first tutorial I made about Bricks in order to include this and other things I have learned over the days.
Really appreciate your help, much love!
@digitalgravy So good that you were not allowed to remove the post!!!
Older post reply - but for anyone else searching how to do something similar, in my case I wanted to check how to add a ‘repeatable’ section or ‘block’ (which could have been but wasn’t a ‘hero section’) of content on select pages to a new client site. So very similar to the above general scenario and so fast forward 2 years the other two easy (and great) ways of doing this are to:
Create a new ‘section’ or ‘single’ template (in Bricks)
Add your unique content (dynamic or static) in the template (either type)
Insert that ‘template’/content via Bricks’ ‘template’ element/widget.
Or you can use the template’s shortcode and use that (via Bricks’ ‘shortcode’ element).
The use case for me was to have the same content centrally editable but added into the flow of different pages at different page locations but you might also want to create ‘something’ that you intend to edit once (the Bricks template) but add to other site templates etc - all very nicely handled by Bricks - in case that helps anyone else.