List all posts from each categories ( taxonomies) in wordpress
<?php
// Fetch All Service Categories & List their posts
$service_categories = get_terms(array(
'taxonomy' => 'service_type',
'parent' => 0
));
foreach ($service_categories as $service_category) {
echo '<li>' . $service_category->name . '</li>';
$serive_detail = get_posts(array('service_type' => $service_category->slug, 'post_type' => 'service', 'posts_per_page' => -1));
// var_dump($serive_detail);
foreach ($serive_detail as $serivep) {
echo $serivep->post_title;
echo $serivep->post_content;
echo "<br><br>";
}
}
?>