Skip to main content
Tweeted twitter.com/#!/StackWordPress/status/40054047352291328

Exclude Sticky posts from Main Query break Pagination !!!

edited tags
Link
scribu
  • 13.2k
  • 38
  • 49
Source Link
Nypam
  • 170
  • 10

Exclude Sticky posts from Main Query break Pagination !!!

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 !

Cheers.

/* 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
        );
        query_posts($args);
    }
}