Paginate wp_query while utilizing post__not_in
I'm currently running a wp_query like this:
?php
$the_query = new WP_Query( array(
'post_type' = 'photos',
'posts_per_page' = '2',
'post__not_in' = array(3),
'paged' = $paged
)
);
?
?php while ( $the_query-have_posts() ) : $the_query-the_post(); ?
?php the_title(); ?
?php endwhile; ?
I then have some pagination at the bottom as such:
?php next_posts_link(); ?
?php previous_posts_link(); ?
Say I have 11 posts that the query would return but one of them has the id of '3'. This means that I have 10 total posts and should return a number of 'next' links. For whatever reason at the end of those pages, there will be a 'next' link that links to a page that is blank.
I believe this empty page is the post I'm attempting to exclude with 'post__not_in'.
How can I exclude posts from my wp_query and still have accurate pagination?
Topic exclude wp-query pagination Wordpress
Category Web