首页 wordpress开发之排除于输出非置顶文章代码

wordpress开发之排除于输出非置顶文章代码

沐辰客栈 2022-04-15 02:40:04 0 228
    <?php
           $args = array(
                  'post_type' =>'post',
                  'post__in'=>get_option( 'sticky_posts' ) //只输出置项的文章
                  //'post__not_in'=>get_option( 'sticky_posts' ) //排除置项的文章 
           );
           $query = new WP_Query( $args );
           $i=1;
           while ($query->have_posts()):$query->the_post();
                  ?>
                  <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                  <br />
           <?php
           $i++;
           endwhile;
    ?> 

发表评论