rakeshr

list subcategories with posts below

Mar 17th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. $parentCatName = single_cat_title('',false);
  3. $parentCatID = get_cat_ID($parentCatName);
  4. $childCats = get_categories( 'child_of='.$parentCatID );
  5. if(is_array($childCats)):
  6. foreach($childCats as $child){ ?>
  7. <h2><?php echo $child->name; ?></h2>
  8. <?php query_posts('cat='.$child->term_id);
  9. while(have_posts()): the_post(); $do_not_duplicate = $post->ID; ?>
  10. <!-- POST CODE -->
  11.  
  12. <!-- END POST CODE -->
  13. <?php
  14. endwhile;
  15. wp_reset_query();
  16. }
  17. endif;
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment