WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. brometheus55
    Member
    Posted 11 months 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. alchymyth
    The Sweeper & Moderator
    Posted 11 months ago #

    where exactly in what template are you using that code?

    does the problem persist if you temporarily deactivate all plugins?

  3. Zulfikar Nore
    Member
    Posted 11 months 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
    Member
    Posted 11 months 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.

    Zulfikar-

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

  5. tzweers
    Member
    Posted 11 months ago #

    @Zulfikar Nore

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

  6. brometheus55
    Member
    Posted 11 months ago #

    I found my fix to the original problem using this:

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

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.