我想显示所选标签的所有相关帖子,我的目的是在我的帖子中显示所有标签,如果有人单击标签,那么它应该重新指向我的标签模板tag.php
. 但我无法显示与标签相关的所有帖子(我在帖子中单击了这些帖子)。我的标签
<div class="single_detail">
<div class="single_text">
<?php
//GET THE TAG NAME FORM THE QUIRED OBJECT
$term = get_queried_object();
$tag_name = $term->name;
$args=array(\'posts_per_page\'=>5, \'tag\' => $tag_name);
$wp_query = new WP_Query( $args );
if( $wp_query->have_posts()) :
while ( $wp_query->have_posts() ) : $wp_query->the_post();
?>
<div class="blog_box">
<a href="<?php the_permalink(); ?>">
<span class="blog_author">By <strong><?php echo get_the_author(); ?></strong> Posted <strong><?php the_time(\'F j, Y\') ?></strong></span>
<h3><?php the_title(); ?></h3>
<p><?php echo substr(get_the_excerpt(), 0,100); ?></p>
<span class="read_more">Read more</span>
</a>
</div>
<?php endwhile;
endif;
?>
</div> <!-- end of posts details -->
如何获取所选标签的所有帖子?