WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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