It’s now showing the first date at the top of the page. Now all I need is to get it to the rest.
I’m not good enough at php to even modify the code, but I’ll see what I can do. Thanks for the help.
No problem!
Are you sure that the posts you’re testing with were actually made on different days?
Yea. I just put a test post up now. The leading date changed, but the previous date didn’t move down with the last post.
I’m probably doing something wrong. Not sure what..
Oh, I bet you’re not ordering by post date descending. Add this code *right before* you begin the loop. I’ll leave the before and after lines in tact so that you know exactly where to place it.
$datetime = null;
// the following lines are new
global $query_string;
query_posts( $query_string . '&orderby=date&order=DESC' );
// end new lines
if ( have_posts() ) : while ( have_posts() ) : the_post();
Since you’re using query_posts to alter the query, you may also wish to reset it after the loop:
<?php endwhile; ?>
<?php else: ?>
<?php get_template_part( 'loop-error' ); // Loads the loop-error.php template. ?>
<?php endif; ?>
<?php
// the following lines are new
rewind_posts();
wp_reset_query();
// end new lines
?>
Wait… >.> I feel so stupid!! If the dates are descending then of course post dates won’t get larger…they’ll get smaller!!!
Change the comparison operator to less-than hehe.
This:
} else if ( (int) get_the_time( 'Ymd' ) > $datetime ) {
to this:
} else if ( (int) get_the_time( 'Ymd' ) < $datetime ) {
I so hope this works!
Holy crap. It works! Thank you SO much. I really appreciate your help.
Yay 🙂 So glad I could help! Take care!