Site logo

Archived topic

Add Conditional statement to php snippit

3 replies · Started by Tim on January 13, 2017

Viewing posts 1–4 of 4

Hello,

I added a sticky buttons plugin to my site and it said to:
Place <?php if(function_exists('wordpress_Sticky_btns')) {wordpress_Sticky_btns();}?> in your templates

So I added it to Inside Content Container and it works, but is there a way to add to this so it only outputs on Home page and Singles page

I tried this but no luck;
<?php if(is_home() && is_single() && function_exists('wordpress_Sticky_btns')) {wordpress_Sticky_btns();}?>

I tried searching on this but could not get it

Thanks

You were close!

Try this:

<?php if ( ( is_home() || is_single() ) && function_exists( 'wordpress_Sticky_btns' ) ) {
    wordpress_Sticky_btns();
}?>

Thank you

You're welcome :)

This archived topic is closed to new replies.