一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

WordPress置顶文章与非置顶文章的列表分离

时间:2013-08-03 编辑:简简单单 来源:一聚教程网

置顶文章归置顶的样式,在循环文章列表中排除置顶文章。

Case1置顶列表解决方案:

在要插入置顶文章列表的地方写入一下语句:

 代码如下 复制代码

1, 'post__in' => get_option('sticky_posts'), 'caller_get_posts' => 1 )); if (have_posts()) : while (have_posts()) : the_post(); ?>

将置顶文章的代码表示如下:

 代码如下 复制代码


最后结束置顶循环列表:

 代码如下 复制代码


 


Case2排除置顶文章的列表解决方案:

 代码如下 复制代码



在原先的循环语句上替换如下去除置顶列表的代码:

 代码如下 复制代码


 $args=array(
 'post_status' => 'publish',
 'paged' => $paged,
 'caller_get_posts' => 1,
 'posts_per_page' => $post_num
 );
 query_posts($args);
 if ( have_posts() ) : while ( have_posts() ) : the_post();
?>  
 

Ok!赶紧更新index.php,刷新下首页看看

热门栏目