I have run into some trouble with pagination using a custom query to display both private and published posts from a category.
Here's my custom query:
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query_args = array(
'post_type' => 'post', 'post_status' => array('private', 'publish'),
'cat' => '1208',
'posts_per_page' => 20, 'paged' => $paged, );
$the_query = new WP_Query( $query_args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
endwhile;
endif;
wp_pagenavi( array( 'query' => $the_query ) );
This code above works properly to logged in users, but i'm using this code to display private posts as "teasers" for guests and the private posts are being displayed but they are not being counted into the pagination calculations so we end up with less pages as it only counts the published posts.
Any idea how i can make wordpress take private posts as well as published posts into the pagination count for this custom query?
I'm stuck! Any ideas welcome! Thanks!
EDIT: Upon further investigation this code works properly if running as a "page" but when i run it as a "category" using template category-name.php wordpress will only count the posts that are "published" in the category and not include the private ones. I'm certain this is a core issue and i need to do something in functions.php to modify the query for this category.