阿里云服务器

wordpress网站中常常需要置顶文章,这样会在首页显示重复

所以在正常排序的文章中需要排除掉置顶文章,下面给大家提供一个简单的方法解决这个问题

在页面中用如下代码调用文章即可;

<?php
$the_query = new WP_Query( array( 'post__not_in' => get_option( 'sticky_posts' ) ) );
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();?> 



<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

用以上代码替换掉原来的调用代码,就可以排除置顶文章了!

相关阅读: