<?php $cat_terms = get_terms( array('category'), array( 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', 'number' => 6 //specify yours ) ); if( $cat_terms ) : foreach( $cat_terms as $term ) : //var_dump( $term ); echo '<h3>'. $term->name .'</h3>'; $args = array( 'post_type' => 'post', 'posts_per_page' => 10, //specify yours 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => $term->slug, ), ), 'ignore_sticky_posts' => true //caller_get_posts is deprecated since 3.1 ); $_posts = new WP_Query( $args ); if( $_posts->have_posts() ) : while( $_posts->have_posts() ) : $_posts->the_post(); echo '<h5>'. get_the_title() .'</h5>'; endwhile; endif; wp_reset_postdata(); //important endforeach; endif;