Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using WP 3.0.3 and I would like to exclude sticky posts from my query:

This doesn't seem to work:

<?php query_posts( 'posts_per_page=9&cat=-1,-2&ignore_sticky_posts=1' );?>

To get JUST the sticky post I use the following:

$sticky = get_option('sticky_posts');
$args = array(
    'posts_per_page' => 1,
    'post__in'  => $sticky
);
query_posts($args);
share|improve this question

3 Answers 3

up vote 3 down vote accepted

ignore_sticky_posts was introduced in WordPress 3.1. Before this version, you can use caller_get_posts, which will have the same effect (this option was used when you queried the posts via get_posts(), which uses the same WP_Query class in the background, but should ignore sticky posts). The name was a bit confusing, and thus changed in 3.1.

share|improve this answer

Have you tried using

query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ) ) );
share|improve this answer

'post__in' will be changed to 'post__not_in' in your code. Thanks!

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.