I’ve found tons of code and plugins to do various things; from show posts for specific cats, subcats of a cat, etc.. BUT, I cannot for the life of me find, nor do I know the WP API well enough to do what I need with it..

Here is what I’m trying to accomplish:

Display a UL of all subcats within Cat31, and the posts for each of those subcats:

  • SubCat1

    • Post 1
    • Post 2
  • SubCat2

    • Post 1
    • Post 2
  • SubCat3

    • Post 1
    • Post 2

It’s pretty straight forward, but all the loops I have tried fail either at the subcat loop or the post loop (one or the other works, I cannot get them both to work..)

So, unless I can find a plugin to do this (I’d prefer to code this into a template file!) then I need to figure out how to:

Loop Subcats within Cat31 while looping subcasts, loop posts for each subcat

Any help is GREATLY appreciated!

2 Answers
2

Question was answered on another site.. thank you!
BTW, the code that accomplished what I needed was:

$categories =  get_categories('child_of=31');  
foreach  ($categories as $category) {
    //Display the sub category information using $category values like $category->cat_name
    echo '<h2>'.$category->name.'</h2>';
    echo '<ul>';

    foreach (get_posts('cat=".$category->term_id) as $post) {
        setup_postdata( $post );
        echo "<li><a href="'.get_permalink($post->ID).'">'.get_the_title().'</a></li>';   
    }  
    echo '</ul>';
}

Leave a Reply

Your email address will not be published. Required fields are marked *