WordPress 中排除置顶文章
admin 阅读:80 2024-03-02
WordPress 中排除置顶文章,在 wordpress 的查询中设置参数:’post__not_in’ => get_option(‘sticky_posts’) 即可排除置顶文章,示例代码如下:
<?php
$recentPosts = new WP_Query(array('post__not_in' => get_option('sticky_posts')));
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<li> <a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php echo get_the_title(); ?></a></li>
<?php endwhile; wp_reset_query();?>
声明
1、部分文章来源于网络,仅作为参考。 2、如果网站中图片和文字侵犯了您的版权,请联系1943759704@qq.com处理!



