Forums

[resolved] Displaying posts on static page - date issue (3 posts)

  1. jo6891
    Member
    Posted 2 years ago #

    Hi There,

    I have a problem...

    I have a static home page and on there I display 5 latest posts with the the date and then the amount of characters limited to 35. This works fine. However, if there are 2 or more posts entered on the same date, then the date is only shown next to the most recent post, but I actually want the date to be show on them all, regardless. Please help!

    <div id="home_latest_news">
    <h1>Latest News</h1>
    <?php $my_query = new WP_Query('showposts=5'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <div class="news_entries">
    <div>">
    <?php the_date('d/m/y');?>
    </div>
    <div>">
    <?php $content = get_the_content();
    $content = strip_tags($content);
    echo substr($content, 0, 45);
    ?>
    ...
    </div>
    </div>
    <?php endwhile; ?>
    </div>

  2. MichaelH
    Volunteer
    Posted 2 years ago #

    From Codex

    SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() with a date-specific format string.

  3. jo6891
    Member
    Posted 2 years ago #

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic