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);
    }
}

1 Answer
1

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

Leave a Comment