• Resolved coder4web

    (@coder4web)


    Hello!
    Thanks a lot for your great work, LZB is must have WP plugin, especially for developers!

    I have reusable lazyblock “Main menu” and decided use it as global site header, to avoid place it on each page in admin.

    Is any way to call lazyblock programmatically from PHP code (index.php etc)?
    Thanks!

    • This topic was modified 1 year, 12 months ago by coder4web.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter coder4web

    (@coder4web)

    Found working example in this forum with PHP call for reusable block:

    $reuse_block = get_post(123); // Where 123 is the post id
    $reuse_block_content = apply_filters('the_content', $reuse_block->post_content);
    echo $reuse_block_content;

    This code works with lazyblock too, display content only once (even if lzb still placed on the page), so I’m good with it, but maybe you know another lzb-way ??

    Plugin Author Nikita

    (@nko)

    Hey.

    Thank you for your kind words.

    I don’t have a better solution to render reusable blocks. Most probably it is working better in the FSE themes, as these themes use HTML templates without PHP.

    Regards, nK.

    another way to do it that seems slightly more elegant

    <?php echo do_blocks(get_post_field('post_content', 123)) ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is any way to call lazyblock from PHP code?’ is closed to new replies.