WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Getting is_home to work

[Resolved] Getting is_home to work

  • Hi!

    I’ve been trying to get is_home to display a plugin in my sidebar, but on the home page only. I looked up the codex and this is what I came up with:

    <?php if ( is_home() ) {
    <?php if(function_exists('tptn_show_daily_pop_posts')) tptn_show_daily_pop_posts(); ?>
    }
    ?>

    Is this code correct? Because wherever I inject it into my sidebar.php, everything in it goes blank. The goal would be to have it appear after the dynamic widgets part.

    Sidebar code: http://pastebin.com/zHe6nNBt

    By the way the plugin code works without the is_home commands. I think I’ve produced a faulty code.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael
    Moderator

    @alchymyth

    you are using too many php tags –

    <?php if ( is_home() ) {
    if(function_exists('tptn_show_daily_pop_posts')) tptn_show_daily_pop_posts();
    }
    ?>

    or:

    <?php if ( is_home() && function_exists('tptn_show_daily_pop_posts') ) tptn_show_daily_pop_posts(); ?>

    Are you defining the home page as a page in Settings > Reading?

    If so is_home() is not used and is_front_page() is.

    Hi alchymyth, removing the php tags did the trick. Thanks.

    Aaron, is_home is appropriate for my needs as I don’t use a static front page 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Getting is_home to work’ is closed to new replies.