WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Only display date on homepage (7 posts)

  1. jbj101
    Member
    Posted 7 years ago #

    Currently, I am using the Travelogue theme and it displays the date next to each post on every page. I only want it to display the date next to posts on the home page. I have tried using the is_home() condition without success. Any help would be greatly appreciated. I'm sure this is very simple and I am just missing something stupid. Thanks.

    [moderated: snip]
    <div class="post">
    <div class="post_cal">
    <?php $postraw = the_date('D, j, M, y', '', '', FALSE);
    $postdate = explode(', ', $postraw); ?>
    <div class="dayname"><?php echo $postdate[0]; ?></div>
    <div class="daynum"><?php echo $postdate[1]; ?></div>
    <div class="month"><?php echo $postdate[2]; ?> '<?php echo $postdate[3]; ?></div>

    <div class="year"></div>
    </div>

    [moderated: snip]

  2. Chris_K
    Member
    Posted 7 years ago #

    Does this theme have a single.php as part of it?

  3. jbj101
    Member
    Posted 7 years ago #

    unfortunately, no.

  4. Chris_K
    Member
    Posted 7 years ago #

    Hmm... ok, so after
    <div class="post">

    add

    <?php if (is_home()) { ?>

    and it looks like after
    <div class="year"></div>
    </div>

    add
    <?php } ?>

    Try that?

    Or, copy index.php to single.php and remove that date code.

  5. jbj101
    Member
    Posted 7 years ago #

    works!!! i'm new to php and was totally using the wrong syntax. thanks so much for your help!

  6. Chris_K
    Member
    Posted 7 years ago #

    glad it worked. Go ahead and mark this thread as "resolved" please?

    And happy blogging!

  7. vkaryl
    Member
    Posted 7 years ago #

    You should also be able to copy single.php from the default theme into your theme folder and have it work more "normally".

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.