0

I have a "featured" area in header.php that displays the content of the latest sticky post:

$last_sticky_post = get_post(end(get_option('sticky_posts')));
if(!empty($last_sticky_post)):
setup_postdata($last_sticky_post);
the_content();
endif;

problem is that the same post now renders below it in the Loop - how can I suppress sticky posts from appearing at all in the loop?

1

Before your loop do:

$args = array(
    'ignore_sticky_posts' => 1
);
$query = new WP_Query( $args );
// The Loop
while ( $query->have_posts() ) : $query->the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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