Twenty Thirteen
[resolved] Trouble with is_home command (6 posts)

  1. brometheus55
    Posted 2 years ago #

    Hello I'm having trouble using this command (and a couple variations i tried) to add content to only the front page of my blog via index.php (posts not static page). No matter what i try, the content always ends up on every page.

    <?php if (is_home()) : ?>
    Homepage only content
    <?php endif; ?>

    Have used this with other blogs fine but not working well for me with Twenty Thirteen. Any advice would be helpful.

  2. Michael
    Forum Moderator
    Posted 2 years ago #

    where exactly in what template are you using that code?

    does the problem persist if you temporarily deactivate all plugins?

  3. Zulfikar Nore
    Posted 2 years ago #

    Sometimes is_home does not work - use is_front_page instead like so

    <?php if ( is_front_page() ) : ?>
         Homepage only content
    <?php endif; ?>

    Be sure to be doing this in a child theme though as you will loose it all come the next update if you edit the parent theme.

  4. brometheus55
    Posted 2 years ago #

    It would be in the index.php between

    <div id="primary" class="content-area">
    <div id="content" class="site-content" role="main">

    OR anywhere just outside on either top or bottom of this code.

    I just tested it on a fresh wordpress install with all plugins deactivated and it still persists.

    I feel as if my approach may be off as this isn't working in twenty twelve either. It has worked in the past on many themes for me however and this fix is found all over the internet.


    I found that snippet when I was searching. I tried it and it doesn't work any differently.

  5. tzweers
    Posted 1 year ago #

    @Zulfikar Nore

    Thanks that worked for me in my child theme of twenty thirteen

  6. brometheus55
    Posted 1 year ago #

    I found my fix to the original problem using this:

    if (is_home() && strpos($_SERVER['REQUEST_URI'], "/page/") === false) {

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic


No tags yet.