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

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

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. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 9 months, 11 days ago Alex S
    Hi, I Work Here

    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. 9 months, 15 hours ago frafor

    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. 8 months, 27 days ago Andrew Misplon
    Hi, I Work Here

    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.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More