Skip to content

Instantly share code, notes, and snippets.

@tjtate
Created August 19, 2013 21:20
Show Gist options
  • Save tjtate/6274316 to your computer and use it in GitHub Desktop.
Save tjtate/6274316 to your computer and use it in GitHub Desktop.
$counter = 0;
$ref_month = '';
$monthly = new WP_Query(array('posts_per_page' => 10));
if( $monthly->have_posts() ) : while( $monthly->have_posts() ) : $monthly->the_post();
if( get_the_date('mY') != $ref_month ) {
if( $ref_month ) echo "\n".'</ul>';
echo "\n".'<h6>'.get_the_date('F').'</h6>';
echo "\n".'<ul>';
$ref_month = get_the_date('mY');
$counter = 0;
}
if( $counter++ < 5 ) echo "\n".' <li><a href='.get_permalink($post->ID).'>'.get_the_title($post->ID).'</a></li>';
endwhile;
echo "\n".'</ul>';
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment