Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:MCincubus/group by day

<?php if (have_posts()) : ?>
<?php $last_day = false; ?>

<?php while (have_posts()) : the_post(); ?>

<?php if (!$last_day) {
          echo '<div class="day">';
          the_date('', '<h2 class="date">','</h2>');
          $last_day = get_the_time('Y-m-d');
} elseif ($last_day != get_the_time('Y-m-d')) {
          echo '</div><div class="day">';
          the_date('', '<h2 class="date">','</h2>');
          $last_day = get_the_time('Y-m-d');
}
?>
          

<!-- entry stuff here -->
<?php endwhile; ?>

</div> <!-- class="day" -->

<?php else : ?>
        <h2><span>Not Found</span></h2>
    <?php endif; ?>