0

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) { ?>

1 Answer 1

0

If 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.com/wp-themes/how-to-exclude-sticky-posts-from-the-loop-in-wordpress/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.