• Hi, I’m havng a problem with a loop. I exclude all the posts in one category with this code.

    <?php if ( have_posts() ) :
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args=array(
    			'category__not_in' => array('9'),
    			'posts_per_page' => 5,
    			'paged' => $paged
    		);
    
    		$my_query = new WP_Query($args);
    
    		while ( $my_query->have_posts() ) : $my_query->the_post();
    	?>
    
    //here goes the post routine

    It does weel and excludes category 9, but when I set the navigation div and I call next_posts_link() and previous_posts_link(), it generates blank pages. It’s as if the excluded posts were still counting for the pagination and the iteration even not being shown.

    I’ve been looking for a solution or someone who has gone through this for hours and I can’t fin a solution, so I hope someone can help me here with this issue.

    Thank you very much.

  • The topic ‘Excluding category from loop generates blank pages on previous/next links’ is closed to new replies.