admin管理员组文章数量:1322172
I'm trying to exclude 3 Sticky posts from my blogs loop, I tried some snippets of code, but with no success. I could use some help.
<?php if ( $posts->have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( $posts->have_posts() ) : $posts->the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<div class="clearfix"></div>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
<div class="clearfix"></div>
<?php $wp_query = new WP_Query($args); global $wp_query; if ($wp_query->max_num_pages != 1) { ?>
I'm trying to exclude 3 Sticky posts from my blogs loop, I tried some snippets of code, but with no success. I could use some help.
<?php if ( $posts->have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( $posts->have_posts() ) : $posts->the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<div class="clearfix"></div>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
<div class="clearfix"></div>
<?php $wp_query = new WP_Query($args); global $wp_query; if ($wp_query->max_num_pages != 1) { ?>
Share
Improve this question
edited Sep 16, 2020 at 7:57
fuxia♦
107k38 gold badges255 silver badges459 bronze badges
asked Sep 16, 2020 at 6:03
Ioannis PolitidisIoannis Politidis
11 bronze badge
1 Answer
Reset to default 0If you want to exclude sticky posts then you can use it.
<?php
$args = array(
'posts_per_page' => 10,
'ignore_sticky_posts' => 1
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
?>
For More details:
https://www.wpbeginner/wp-themes/how-to-exclude-sticky-posts-from-the-loop-in-wordpress/
本文标签: Exclude Sticky Posts as everyone
版权声明:本文标题:Exclude Sticky Posts as everyone! 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742117550a2421538.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论