$index = 'A';
$terms = get_terms('manufacturer');
foreach ($terms as $term) {
if($index != strtoupper(substr($term->name, 0, 1))) {
$index = strtoupper(substr($term->name, 0, 1));
echo '<h1>'. $index . '</h1>';
}
?>
<h2><?php echo $term->name; ?></h2>
<?php $args = array( 'post_type' => 'cars', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'manufacturer',
'field' => 'slug',
'terms' => array($term->slug)
)
)
);
// ============================= OUTPUT ==============================
$loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();
the_title('<h3>', '</h3>');
the_content();
endwhile;
}