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

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.

| improve this answer | |

Have you tried using

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

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

| improve this answer | |

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.