[Resolved] Add Conditional statement to php snippit

Home Forums Support [Resolved] Add Conditional statement to php snippit

Home Forums Support Add Conditional statement to php snippit

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #263830
    Tim

    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

    #263919
    Tom
    Lead Developer
    Lead Developer

    You were close!

    Try this:

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

    Thank you

    #264059
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.