你的位置: 小文收集 > WP相关 > 阅读文章
您还没有登录,是位游客!  [ 注册 | 登录 ] 2010年09月05日

调用第一篇最新文章

厄,到处游荡 看到下面的代码就复制,粘贴过来了。第六感告诉我以后俺会用得到的………%…¥^ 6¥选取最新的一篇文章的基本代码:

<?php query_posts(‘showposts=1′); while (have_posts()) : the_post(); ?>

<h3><a href=”<?php the_permalink() ?>” title=”<?php the_title(); ?>” rel=”bookmark”><?php the_title(); ?></a></h3>

<?php the_excerpt(‘Continue Reading &raquo;’); ?>

<?php endwhile; ?>

‘showposts=1′表示选取第一篇文章哦

<?php query_posts(‘showposts=4&offset=1′); while (have_posts()) : the_post(); ?>

‘showposts=4&offset=1′); 表示选取4篇文章,去除第一篇文章,也就是选取除去第一篇文章外的最新4篇文章

<?php query_posts(‘showposts=4&offset=1&cat=2′); while (have_posts()) : the_post(); ?>

‘showposts=4&offset=1&cat=2′ 表示选取分类ID为2的4篇文章,去除分类ID为2第一篇文章,也就是选取除去第一篇文章外的最新4篇文章

  • 文章作者:xiao文
  • 属于分类:WP相关
  • 本文标签:
  • 流行热度:已有1,356人围观
  • 生产日期:2009年01月25日
  1. 平平 说: 回复他/她

    我一直没搞懂 你第一段里的 6¥ 绝对不是乱码

    • xiao文 说:

      貌似,这就是乱码… Orz

 表情:O(∩_∩)O o(︶︿︶)o ㄒ△ㄒ!!! ◕‿◕ ●﹏● o(≧v≦)o ~(@^_^@)~