Conquercplusplus's Blog

February 10, 2010

如何让WordPress列出某一分类最新发表的文章(Recent Posts)

Filed under: wordpress — conquercplusplus @ 2:29 am

ordpress的Recent Posts功能不错,有利于提高pv量,给读者带来更好的体验感受,为了更好的改善用户体验,有时候需要调取某一个分类最新发表的文章(即Recent Posts),那么如何才能读取呢,根据Wordpress首页读取文章的语句我们可以变相实现,现在就来一起学习一下吧:

<?php query_posts(‘category_name=Foobar2000&showposts=5′); ?>
<?php while (have_posts()) : the_post(); ?>
        <li><a href=”<?php the_permalink(); ?>”>
          <?php the_title(); ?>
          </a>  </li>
        <?php endwhile; ?>

其中“category_name=Foobar2000”是读取分类“Foobar2000”的Recent Posts(最新发表的文章),“showposts=5”是读取最新的5条Recent Posts,使用的时候把这两项修改成你自己的就可以了。

出自:http://anysns.com

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: WordPress Classic. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.