您没有说明类别id的来源,也没有说明类别标题的样式,也没有说明帖子标题是否应该链接到单个帖子;因此,只有基本结构:
<?php
$cat_id = 137;
echo \'<div class="category-title">\'.get_category($cat_id)->name.\'</div>;
$cat_posts = get_posts(array(\'category__in\' => array($cat_id), \'posts_per_page\' =>5));
if($cat_posts) {
echo \'<ul class="category-posts">\';
foreach($cat_posts as $cat_post) {
echo \'<li class="category-post">\'.get_the_title($cat_post->ID).\'</li>\';
}
echo \'</ul>\';
}
?>