WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Getting is_home to work (4 posts)

  1. ggg377
    Member
    Posted 1 year ago #

    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.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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(); ?>
  3. Aaron
    Member
    Posted 1 year ago #

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

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

  4. ggg377
    Member
    Posted 1 year ago #

    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 :)

Topic Closed

This topic has been closed to new replies.

About this Topic