I have a small problem with this function ! I would like to exclude all sticky post from my query but when I do it, it breaks my pagination. In the following code, when I remove the "'post__not_in' => $sticky" my pagination works like a charm...

Any advice would be much appreciated !


/* Exculde STICKY from the main QUERY */
function exclude_cat(){
    if (is_home()) {
        $paged = (get_query_var('page')) ? get_query_var('page') : 1;
        $sticky = get_option( 'sticky_posts' );
        $args = array(
        'category__not_in' => array( 71 ),
        'ignore_sticky_posts' => 1,
        'post__not_in' => $sticky,
        'paged' => $paged
  • You don't need the post__not_in arg if you're using ignore_sticky_posts(caller_get_posts pre 3.1)... or at least it shouldn't be needed. – t31os Feb 22 '11 at 13:56
  • If I remove the post__not_in arg, sticky posts appear in my query. – Jk_ Feb 22 '11 at 14:05
  • What version are you on, you'll need to use caller_get_posts instead of ignore_sticky_posts if you're running anything less than WordPress 3.1 (eg. 3.0.5) – t31os Feb 22 '11 at 14:33
  • I'm on 3.0.5 so I replaced ignore_sticky_posts by caller_get_posts, however if I remove the line post__not_in the pagination appears but the sticky posts too... Very frustrating. – Jk_ Feb 22 '11 at 15:02
  • 2
    This get_query_var('page') should actually be get_query_var('paged'), see if changing that fixes the problem, alongside the other changes suggested. – t31os Feb 22 '11 at 15:19

As pointed out by @t31os in the comments, get_query_var('page') should actually be get_query_var('paged').

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.