Site logo

Archived topic

I need to put beaver builder shortcode in a hook for posts only

10 replies · Started by Michael Mancini on September 5, 2017

Viewing posts 1–11 of 11

Hi,

Is this possible? A beaver builder shortcode looks like this: [fl_builder_insert_layout slug="my-post-slug"]

How can I put this in a hook that only shows on posts?

Thanks,
Michael

Michael -

This should do it :)

<?php if ( is_single() ) { ?>
<?php echo do_shortcode( '[fl_builder_insert_layout slug=”my-post-slug”]' ); ?>
<?php } ?>

Cheers!
Lyle

Hi Lyle,

I just tried it and it didn't work.

Michael

Did you tick the Execute PHP box?

Yes.

That's odd. I just tried it on a test site and it works fine :) Which hook location are you using?

I tried Before Footer and After Content. Using this:

<?php if ( is_single() ) { ?>
<?php echo do_shortcode( '[fl_builder_insert_layout slug=”custom-grid-recent-posts”]' ); ?>
<?php } ?>

I am getting this error on every page. Image

This should be the code:

<?php if ( is_single() ) {
    echo do_shortcode( '[fl_builder_insert_layout slug="custom-grid-recent-posts"]' );
} ?>

Hi Tom,

That worked.

Thanks,
Michael

You're welcome :)

This archived topic is closed to new replies.