This code was not tested!
Tested
Based on @Pieter Goosen answer
.
<?php
$post_type="item";
$taxonomy = 'item_tags';
// count the number of terms for correct pagination
$term_count = get_terms( array (
'taxonomy' => $taxonomy,
'fields' => 'count',
) );
// define the number of terms per page
$terms_per_page = 10;
// find out the number of pages to use in pagination
$max_num_pages = ceil( $term_count / $terms_per_page );
// get the page number from URL query
$current_page = get_query_var( 'paged', 1 );
// calculate the offset, if there is one.
$offset = 0; // initial
// or changed the if not the first (0)
if( ! 0 == $current_page) {
$offset = ( $terms_per_page * $current_page ) - $terms_per_page;
}
// get all taxonomy terms
$terms = get_terms( array (
'taxonomy' => $taxonomy,
'order' => 'ASC',
'orderby' => 'name',
'number' => $terms_per_page,
'offset' => $offset,
) );
echo '<dl>';
// cycle through taxonomy terms
foreach ( $terms as $term ) {
echo '<dt>' . $term->description . '</dt>';
echo '<dd>';
echo '<ul>'; // because you can't have multiple <dd>s for one <dt>
// cycle through posts having this term
$items = get_posts( array (
'post_type' => $post_type,
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'terms' => $term->term_id,
),
),
'numberposts' => -1, // different from WP_Query (see Code Ref)
) );
// essential, see comments inside foreach() loop
global $post;
foreach ( $items as $item ) {
// assign $item to global $post
$post = $item;
// and now set up
setup_postdata( $post );
echo '<li><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></li>';
// wp_reset_postdata(); // see below
}
wp_reset_postdata(); // moved outside the foreach() loop
// end posts cycle
echo '</ul>';
echo '</dd>';
}
// end term cycle
echo '</dl>';
// Pagination
// See the Code Reference for more arguments
echo paginate_links( array (
'total' => $max_num_pages,
'current' => $current_page,
) );