Help Please! Single page template for Gutenberg and Bricks content

Hello Everyone,

I have been using Bricks for a while now and I have been getting along pretty well, doing normal stuff and developing some custom features too. However there is one very frustrating issue I cannot solve and I am thinking that maybe I am approaching it in the wrong way.

I have some general pages that have Gutenberg content like Imprint, Privacy Policy, etc. And of course I have pages with Bricks content with custom layout.

I thought I could have a Single Page template that I could use to display either Bricks or Gutenberg content on that template. So first I set the condition to use this template if the post type is a Page.

Then I created the layout like this:

You can see that there is the bare Post Content element that is set to work from the Bricks content source. There are no wrappers for it as I format those pages on their specific Bricks editor page.

Under that I wanted to add some wrapper and fancy stuff around the Gutenberg content if there is Gutenberg content. But displaying those elements is conditional. Somewhere I googled that the condition should be this, but please correct me if I am wrong:

I also digged up in the database that the Pages that I click to render with Bricks get this post meta _bricks_editor_mode = bricks.

So I thought I can use this custom field to conditionally display the Wordpress Gutenberg content if there is Gutenberg content instead of the Bricks content.

But it doesn’t work as intended. Let me explain:

  • If I have Bricks content and Render in Bricks is set: it works properly.
  • If I have Gutenberg content and render in Bricks is set: it doesn’t show the Gutenberg content at all. Why?
  • If I have Gutenberg content and Render in Wordpress is set: It shows the gutenberg content but without any wrapper or fancy stuff. I can understand this as rendering with Wordpress probably doesn’t pulls the Bricks template to display the post.

So how can I properly make a universal template to display Bricks or Gutenberg content? I think I am lost and I appreciate any help! Thank you!

I just found my previous post about this issue.

Can @timmse or any other dev help us out?

Hi Andris,
What if you just check whether post_content (= the block editor content) is not empty?

Actually it worked. I have not thought about this simple solution. Maybe because I thought that the Bricks content is also post content.

Now it makes sense that post_content is just the Wordpress post_content field in the DB.

Thank you again!

Yes, sometimes it’s much easier than you’d think :slight_smile:

No, it’s stored separately in wp_postmeta :v: