WordPress.org

Ready to get started?Download WordPress

Forums

How to seperate a set of posts published on the same day from the others? (2 posts)

  1. wyczes
    Member
    Posted 1 year ago #

    Hi there,

    If you look at this website: http://www.selectism.com/ you will see that daily posts are seperate by a headline "NEWS ON date.....". I would like to have this kind of headline on my blog and seperate a set of posts published on the same day but I do not know how to acheive this effect. Could anybody let me know if there is a plugin or a code that I could use?

    many thanks

    M

  2. vtxyzzy
    Member
    Posted 1 year ago #

    You will need to modify the Loop in your theme by adding a check for a change in the date. It would be something like this:

    if (have_posts()) {
       while (have_posts()) {
          the_post();
          $this_date = the_time('Y-m-d');
          if ($last_date != $this_date) {
             $last_date = $this_date;
             echo "<h2>Posts on $last_date</h2>";
          }
          // Rest of Loop output here
       }
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags