显示从一个特定的类别最近的文章
问题描述:
我想从一个特定的类别显示只从最近的文章后显示从一个特定的类别最近的文章
到目前为止,这是我,但:
<ul>
<?php
$number_recents_post = 5;
$recent_posts = wp_get_recent_posts($number_recents_post);
foreach($recent_posts as $post){
echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' . $post["post_title"].'</a> </li> ';
} ?>
</ul>
我试图把它变成这样,但不工作
<ul>
<?php
$number_recents_post = 5;
$recent_posts = wp_get_recent_posts($number_recents_post . 'cat=3,4,5');
foreach($recent_posts as $post){
echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' . $post["post_title"].'</a> </li> ';
} ?>
</ul>
请让我知道我做错了....
答
你为什么不试试这个(假设你使用Wordpress)
<?php query_posts('post_per_page=5&category_name=yourcategoryname'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php endwhile; else: ?>
<p>An error Message</p>
<?php endif; ?>
+0
我做到了,但现在的问题是,所有的帖子链接到最近的一个... – 2010-05-04 20:11:28
+0
麻烦....抱歉 - 我不知道如何解决:( – codedude 2010-05-04 20:35:18
发生了什么或没有发生什么?你得到什么错误信息? – 2010-05-04 19:08:40
@pekka我没有收到错误信息 – 2010-05-04 19:42:43
嗯,你得到了什么* – 2010-05-04 19:47:09