Guest User

category columns

a guest
Jul 17th, 2010
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.38 KB | None | 0 0
  1. <?php  $cats = get_categories('orderby=count&order=DESC');
  2.  
  3. foreach ($cats as $cat) :
  4.  
  5. echo '<div class="col">';
  6.  
  7. $args = array(
  8. 'posts_per_page' => -1, // max number of post per category
  9. 'cat' => $cat->term_id
  10. );
  11. query_posts($args);
  12.  
  13.      if (have_posts()) :
  14.      $num_of_posts = $wp_query->post_count;
  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>';
  16.      
  17.      while (have_posts()) : the_post(); ?>     
  18.  
  19.             <div <?php post_class() ?> id="post-<?php the_ID(); echo ' '.$marker; ?>">
  20.                 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>             
  21.    
  22.                 <small><?php the_time('F jS, Y') ?>  by <?php the_author();  ?> </small>
  23.            
  24.                 <div class="entry">
  25.                
  26.                
  27.                 <?php the_excerpt(); ?>
  28.                 </div>
  29.  
  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>
  31.                                
  32.             </div>
  33.  
  34.         <?php endwhile; ?>
  35.        
  36.     <?php else :
  37.         echo '<h2>No Posts for '.$cat->name.' Category</h2>';              
  38.      endif;
  39.      
  40.      wp_reset_query(); ?>
  41.    
  42. <?php
  43. echo '</div> <!--end of col-->';
  44. endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment