• Resolved brometheus55

    (@brometheus55)


    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • where exactly in what template are you using that code?

    does the problem persist if you temporarily deactivate all plugins?

    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.

    Thread Starter brometheus55

    (@brometheus55)

    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.

    Zulfikar-

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

    @zulfikar Nore

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

    Thread Starter brometheus55

    (@brometheus55)

    I found my fix to the original problem using this:

    <?
    if (is_home() && strpos($_SERVER['REQUEST_URI'], "/page/") === false) {
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Trouble with is_home command’ is closed to new replies.