View difference between Paste ID: ErbWmcwD and BLNtWqpG
SHOW: | | - or go back to the newest paste.
1-
<?php  $cats = get_categories('orderby=count&order=DESC'); 
1+
<?php  $cats = array('film-reviews','poetry'); //an array with category slugs; 
2
3-
foreach ($cats as $cat) :
3+
foreach ($cats as $cat_slug) :
4-
  
4+
$cat = get_term_by('slug',$cat_slug,'category'); 
5-
echo '<div class="col">'; 
5+
$cat_id = $cat->term_id;
6
7
$args = array(
8-
'posts_per_page' => -1, // max number of post per category
8+
'posts_per_page' => 3, // max number of post per category
9-
'cat' => $cat->term_id
9+
'category__in' => array($cat_id)
10
);
11-
query_posts($args); 
11+
$cat_query = new WP_Query($args); 
12
13-
	 if (have_posts()) : 
13+
	 if ($cat_query->have_posts()) : 
14-
	 $num_of_posts = $wp_query->post_count;
14+
15-
	 echo '<h2>Latest '; if($num_of_posts>1) { echo $num_of_posts; }; echo ' Post'; if($num_of_posts>1) { echo 's';} ; echo ' in '.$cat->name.' Category</h2>';
15+
	 echo '<h2>'.$cat->name.'</h2>';
16
	 
17-
	 while (have_posts()) : the_post(); ?>		
17+
	 while ($cat_query->have_posts()) : $cat_query->the_post(); ?>		
18
19-
			<div <?php post_class() ?> id="post-<?php the_ID(); echo ' '.$marker; ?>">
19+
	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>				
20-
				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>				
20+
21
	<?php the_excerpt(); ?>	
22-
				<small><?php the_time('F jS, Y') ?>  by <?php the_author();  ?> </small>
22+
23-
			
23+
	<?php endwhile; ?>
24-
				<div class="entry">
24+
25
 	<?php else : 
26
		echo '<h2>No Posts for '.$cat->name.'</h2>';				
27-
				<?php the_excerpt(); ?>
27+
28-
				</div>
28+
29
	 wp_reset_query(); ?>
30-
				<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?><br /><?php the_tags('keywords: ', ', ', ' '); ?> </p>
30+
31-
								
31+
<?php endforeach; ?>