2011-02-01 63 views
0

目前我坚持的问题。我的代码是如何按类别获取最新帖子?

$category_ids = get_all_category_ids(); 

    foreach($category_ids as $kk=> $cat_id) { 

     $cat_name= query_posts('posts_per_page=1&orderby=date&order=ASC&cat='.$cat_id); 

    if (have_posts()) :while(have_posts()):the_post 

这是我在loop.php文件写的代码我想是通过只显示1后每个类别的类别只取最新帖子按日期

+0

那么实际问题是什么? 'posts_per_page'参数用于确定每页帖子的数量,因此它应该按日期显示唯一的最新帖子... – 2011-02-01 13:12:22

回答

0

您可以下载像this这样的插件,并了解它是如何完成的。 此外,this线程有东西可以帮助你。它包含一个片段,显示每个类别列表中的最后一篇文章。 Wold会发布代码,但是它会增加格式化,对不起。

相关问题