扩展Maheshwaghmare的工作;
<?
$terms = get_terms( \'CUSTOM_TAXONOMY\' );
if ( ! empty( $terms ) ){ ?>
<div class="POST_TYPE_PLURAL">
<? foreach ( $terms as $term ) {
//print_r($term) // DEBUG;
$term_slug = $term->slug;
$term_name = $term->name;
$term_description = $term->description;
?>
<div class="POST_TYPE_CATEGORY <?=$term_slug; ?>">
<h1 class="section-head"> <?=$term_name; ?> </h1>
<p><?=$term_description; ?> </p>
<?
$args = array(
\'post_type\' => \'CUSTOM_POST_TYPE\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'CUSTOM_TAXONOMY\',
\'field\' => \'slug\',
\'terms\' => $term_slug,
),
),
\'posts_per_page\' => -1,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : ?>
<? while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="POST_TYPE_SINGLE">
<h3> <? the_title(); ?> </h3>
<? // MORE TEMPLATING CODE ?>
</div>
<? endwhile;
endif;
wp_reset_postdata(); ?>
</div>
<? } // foreach
} //if terms
?>