WordPress.org

Support

Support » How-To and Troubleshooting » How to seperate a set of posts published on the same day from the others?

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

  • 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

Viewing 1 replies (of 1 total)
  • 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
       }
    }
Viewing 1 replies (of 1 total)
  • The topic ‘How to seperate a set of posts published on the same day from the others?’ is closed to new replies.