您可以在主题中使用此片段。
//-------------------------------------------------------------
// List Posts by Tag
//-------------------------------------------------------------
// Grab 5 posts by default
function list_posts_by_tag( $tag, $show=5 ) {
global $post;
$posts = query_posts(\'tag=\' . $tag . \'&showposts=\' . $show );
?>
<ul class="tagged-list">
<?php foreach ($posts as $post ) : setup_postdata($post); ?>
<li class="tagged-item"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endforeach;
//Reset Query
wp_reset_query();
?>
</ul>
<?php }
(来自
groupmindmedia.com)
您需要将该代码添加到函数中。php,然后在主题中添加对函数的调用:
list_posts_by_tag( "cats", 5 );