【www.bbyears.com--WordPress】
今天在折腾主题的时候,想给当前分类下显示最新文章列表。就是显示与文章分类相同的最新文章。看到了prower的新主题prowerv4里面有这个功能。当在文章页面时,显示统一分类文章。代码如下:
代码如下cat_name; ?> 下的最新文章
if(is_single()){
$cats = get_the_category();
}
foreach($cats as $cat){
$posts = get_posts(array(
‘category’ => $cat->cat_ID,
‘exclude’ => $post->ID,
‘showposts’ => 10,
));
echo ‘’;
foreach($posts as $post){
echo ‘ID).’”>’.$post->post_title.’’;
}
echo ‘’;
}
?>
标题为“wordpress基础教程下的最新文章”,然后其他的应该很容易看懂的了。