WordPress: Loop All Categories showing All Posts

$post_type = ‘category’;
$args = array(
‘true’ => false,
‘orderby’ => ‘term_id’,
‘order’ => ‘ASC’
);
$tax = get_terms( ‘category’ , $args);
if ( have_posts() ) {
foreach( $tax as $cat ) {
echo $cat->name;
while ( have_posts() ) : the_post();
the_title();
the_content();
endwhile;
}
}


Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>