Forums

[resolved] The date on posts with same date not showed (3 posts)

  1. Ramba
    Member
    Posted 3 years ago #

    Currently I am develop a WP Themes, according to Function Refference in Template Tag (function Reference), I write this code on sidebar.php to show the 5 recent post ordered by date and showed the post date:
    `

      <?php
      $postslist = get_posts('numberposts=5&order=DESC&orderby=date');
      foreach ($postslist as $post) :
      setup_postdata($post);
      ?>

    • "><?php the_title(); ?><span class="floatright"><?php the_date(); ?></span>
    • <?php endforeach; ?>

    `
    the result look fine, post title and permalink worked, but I thinking seriously and take more 3 times to try, why the date not showed on every post, later i realized the post that has no date showed was have same date (day) with other post. See illustration below (according to the code above):
    My Recent Posts

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    No bug, use the template tag, the_time(), instead of the_date().

  3. Ramba
    Member
    Posted 3 years ago #

    now i understand that occur because the_date() template tag make the post in same date grouped so in case above the date just show on the first newer post, smart..! the_time() template tag just show the time, i dont want to use that because on daily updated blog may missleading the visitors. thanks for the respond.

Topic Closed

This topic has been closed to new replies.

About this Topic