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

时间:2018-05-09  来源:WordPress  阅读:

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

Case1置顶列表解决方案:

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

 代码如下

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

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

 代码如下


    id="post-">

       

         

           

             

              " rel="bookmark" title="详细阅读 ">

              ( 于post_modified); ?>更新 )

             

             

             

             

             

             
             
             

    最后结束置顶循环列表:

     代码如下


     


    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,刷新下首页看看

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

    http://m.bbyears.com/wangyezhizuo/41259.html

    推荐访问:
相关阅读 猜你喜欢
本类排行 本类最新