我有一个CPT,在我的CPT论证中,我称之为分类学post_tag
. 当我创建tag.php
文件它不显示所述标签的任何帖子。我的tag.php
:
<?php get_header(); ?>
<section class="row">
<div class="col-md-7">
<p>Tag: <?php single_tag_title(); ?></p>
<?php if ( have_posts() ): while ( have_posts() ): the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php endwhile;
else: ?>
<p>not working</p>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</section>
<?php get_footer(); ?>
在我的研究中,我遇到了“tag.php doesn\'t work with tags on a custom post type post?“但我使用的是我认为默认的标签post_tag
. 当我引用时WP_Query()
标记参数它没有显示如何考虑单击的标记。当我搜索标签时。php我得到Tag Templates 它没有显示任何考虑到所有标记的示例。写一个WP_Query()
对于与标签相关的所有帖子?我确实遇到过wp_get_post_tags()
经过一些研究和阅读”Wordpress get related pages (tag based) - wp_get_post_tags“但是我不理解tag.php的重写,而codex也没有示例。那么我如何才能正确地编写我的tag.php来返回所点击标签的所有帖子呢?