Skip to content

Instantly share code, notes, and snippets.

@davemac
Created October 4, 2011 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemac/1260925 to your computer and use it in GitHub Desktop.
Save davemac/1260925 to your computer and use it in GitHub Desktop.
WordPress output posts by date for current category
<div id="loop" class="clear">
<?php // List Pages by Month
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$cat = get_query_var('cat');
$args = array(
'paged' => $paged,
'cat' => $cat,
'post_type' => 'post',
'posts_per_page' => 10,
);
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post();
$this_dt = get_the_time('F',$post->post_date);
if ($curr_dt != $this_dt) { ?>
<h3 class="month"><?php echo $this_dt; ?> Issue </h3>
<?php } ?>
<div <?php post_class('post clear'); ?> id="post_<?php the_ID(); ?>">
<?php if ( has_post_thumbnail() ) :?>
<a href="<?php the_permalink() ?>" class="thumb"><?php the_post_thumbnail('thumbnail', array(
'alt' => trim(strip_tags( $post->post_title )),
'title' => trim(strip_tags( $post->post_title )),
)); ?></a>
<?php endif; ?>
<div class="post-category"><?php the_category( ' / ' , 'multiple' ); ?></div>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="post-meta">
<span class="post-date"><?php the_time(__('F j, Y')) ?></span> <em>&bull; </em><?php comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments'), '', __('Comments Closed')); ?>
</div>
<div class="post-content"><?php if (function_exists('smart_excerpt')) smart_excerpt(get_the_excerpt(), 55); ?></div>
<?php echo "</div>";
$curr_dt = $this_dt; endwhile; ?>
<?php else :
// Code here for no pages found
endif;
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment