This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

How to detect if entry uses Layout Builder when using Block Editor

2 years ago · Last reply by Andrew Misplon 2 years ago

Hi there,

Sometimes I used to apply a custom class, say ‘editor-sopb’ to the body via body_class filter when SiteOrigin PageBuilder was in use within the page.

I usually checked for

get_post_meta(get_the_ID(), 'panels_data')

Unfortunately, I’ve found out that the Block Editor version of the builder does not save anything in that post meta.

I was wondering if there’s another way to check for it, aside from using siteorigin_panels_render, which may add some overhead for a bool check like that (am I wrong?).

Thanks for all the work you do guys!

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

3
  1. Alex S Staff 2 years, 4 months ago

    Hi Frafor,

    Thanks for getting in touch. The best way of identifying whether a page has a SIteOrigin Layout Block present is to parse the post content using parse_blocks. This will give you an array of all of the blocks used on the page. Iterate that data (there’s some great examples of this at the above link) and check if the blockName equals to siteorigin-panels/layout-block.

    Kind regards,
    Alex

  2. frafor 2 years, 4 months ago

    Hi Alex, thanks for the suggestion!

    I think I’ll iterate via parse_block on save_post and add a custom field to save the outcome

  3. Andrew Misplon Staff 2 years, 4 months ago

    Hi, thanks for your reply. Hopefully, you’ve made progress.

    Cheers

    Andrew

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread