I want get all categor and after that i want get 5 post per category. but my code not work! <?php $categories=get_categories(''); foreach($categories as $category) { echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> '; echo '<p> Cat ID: '. $category->cat_ID. '</p>'; // The Query $id_cat = $category->cat_ID;} $args = array('cat' => $id_cat, 'posts_per_page' => 5, ); query_posts( $args ); // The Loop while ( have_posts() ) : the_post(); echo '<li>'; the_title(); echo '</li>'; endwhile; //} // Reset Query wp_reset_query(); ?>