谢谢你们这么快的反应。非常感谢!
以下是“全局”标记页面的代码(显示默认“post\\u tag”分类法的术语):
<?php
$term_slug = get_queried_object()->slug;
if ( !$term_slug )
return;
else
$loop = new WP_Query( array( \'post_type\' => \'any\', \'tag\' => $term_slug, \'posts_per_page\' => 10 ) );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="entry-content">
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<?php endwhile; // End the loop. ?>
下一个代码示例用于自定义分类查询(显示自定义分类的术语):
<?php
//http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters
$term_slug = get_queried_object()->slug;
if ( !$term_slug )
return;
else
$args = array(
\'tax_query\' => array(
array(
\'taxonomy\' => \'gallery_category\',
\'field\' => \'slug\',
\'terms\' => $term_slug,
\'posts_per_page\' => 10
)
)
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="entry-content">
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<?php endwhile; // End the loop. ?>