Archived topic
Using different content in hooks om homepage
9 replies · Started by Johan on January 8, 2017
Hi support
I want to display different things on my homepage and the rest of the site using the GPHooks. I tri this code but it won't work:
<?php if ( is_front_page() ) : ?>
[fl_builder_insert_layout slug="dkjob-2"]
<?php else; ?>
[fl_builder_insert_layout slug="dkjob-2"]
[fl_builder_insert_layout slug="ritzau"]
[ssbp]
<?php endif; ?>
Try this:
<?php if ( is_front_page() ) { ?>
[fl_builder_insert_layout slug="dkjob-2"]
<?php } else { ?>
[fl_builder_insert_layout slug="dkjob-2"]
[fl_builder_insert_layout slug="ritzau"]
[ssbp]
<?php } ?>
Make sure "Execute PHP" is checked.
Thanks for quick reply!
Works on the front page – but the rest of the pages are breaking ...
Is the code correct? Sorry, I'm not a PHP'er.
There were curly quotes left over from WordPress formatting. Just adjusted the code above, give it another shot :)
Nope, it still breaks the pages :-(
What do you mean by "breaks"? What about the pages are broken?
This is how it should look: https://snag.gy/d79pGq.jpg
This is how it looks after inserting the code: https://snag.gy/C5alRq.jpg
Looks like there's broken markup inside one of those shortcodes. Take a look in each one - each opening element (<div>, <p>, <span> etc..) should have a closing element (</div>, </p>, </span>).
No, even if I removed all the shortcodes the problem persisted.
But this worked (I know one of the shortcodes has changed but that is irrellevant):
<?php if ( is_front_page() ) {
echo do_shortcode( ' [fl_builder_insert_layout slug="dkjob-2"] ' );
}
else
{
echo do_shortcode( ' [fl_builder_insert_layout slug="dkjob-2"] ' );
echo do_shortcode( ' [fl_builder_insert_layout slug="ritzau-3" type="fl-builder-template"] ' );
echo do_shortcode( ' [ssba] ' );
}
?>
Ah, maybe since it's in a conditional it needs the do_shortcode function wrapped around.
Glad you got it working :)