How to get subcategories of a specific category with latest post and image?

I need a sub-category box in sidebar as a Author Box. I want to get all child categories name, image and latest post of a specific category. Parent category is “Author”. “Author” has 3 sub-category “John”,”Dany”,”David”. I need “John”s category name, category url, category image and latest post of “John” and the other categories too. How can i do with loop?

Note: I’m using “Categories Images” plugin for displaying categories images.

Read More

Thanks

Related posts

Leave a Reply

1 comment

  1. That code block is working exactly what I want. Maybe it can be optimised.

    <?php $categories =  get_categories('child_of=573');
    foreach  ($categories as $category) {
    echo '<div>';
    echo '<h1><a href="'.get_category_link( $category->term_id ).'">'.$category->name. '<img src="'.z_taxonomy_image_url($category->term_id).'" /></a></h1>';
    foreach (get_posts('cat='.$category->term_id.'&posts_per_page=1') as $post) {
        setup_postdata( $post );
        echo '<a href="'.get_permalink($post->ID).'">'.get_the_title().'</a>';
    }
    echo '</div>';
    } ?>