在tag.php模板上显示帖子?

Rob*_*Rob 5 php tags wordpress

是否可以创建一个tag.php模板,当您导航到该网址时www.domain.com/tag/architecture/,它将显示所有已使用该特定标记标记的自定义帖子?各种其他标签等等?

我需要在模板中包含哪些代码?

Sun*_*ala 5

是的你可以创建,下面是我用来显示自定义帖子类型"知识"的代码

<?php
global $query_string;
$posts = query_posts($query_string.'&post_type=knowledge');
if ( have_posts() ) while ( have_posts() ) : the_post(); 
?>
<a href="<?php echo get_permalink(get_the_ID()); ?>"><?php the_title(); ?></a>
<?php endwhile; // end of the loop. ?>
Run Code Online (Sandbox Code Playgroud)

这将有助于您了解模板的层次结构http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

在这里使用$ query_string(example)http://codex.wordpress.org/Function_Reference/query_posts