I using custom $wp_query for most of my archive pages like, taxonomy,index,category and author page. Everything working fine, except one weird thing - the author template page pagination failed to work. The pagination stop to work on page 2 it direct to the 404 page. Pagination on other archive page, works perfectly.
Here is my codes for author.php template :
<?php get_header(); ?>
<section id="primary">
<div id="content" role="main">
<?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
?>
<?php toolbox_content_nav( 'nav-above' ); ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'showposts'=> 2,
'paged' => $paged,
'post_type'=> array('cpt1','cpt2'));
$query = new WP_Query( $args );
?>
<?php if ($query ->have_posts() ) : ?>
<h1>Posts from <?php echo $curauth->first_name; ?> </h1>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?></a>,
<?php the_time('d M Y'); ?> in <?php the_category('&');?>
</li>
<?php endwhile; ?>
<?php wp_pagenavi( array( 'query' => $query) ); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'toolbox' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'toolbox' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>
</div><!-- #content -->
</section><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I am using wp_pagenavi plugin for the pagination anyway. Apparently the wp_pagenavi knows there are pages (because it show more than 1 page at the pagination link), but when i goto page two, turns out no post was found (404 page).
I've googled this issue and applied all the suggestion that I searched, still no help. What is the problem?