我对大多数存档页面使用自定义$wp\\u查询,如分类法、索引、类别和作者页面。一切正常,除了一件奇怪的事情——作者模板页面分页失败。分页停止在第2页上工作,它直接指向404页。在其他存档页上分页,效果很好。
这是我的作者代码。php模板:
<?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(); ?>
无论如何,我都在使用wp\\u pagenavi插件进行分页。显然,wp\\u pagenavi知道有页面(因为它在分页链接上显示了不止一个页面),但当我转到第二页时,发现没有找到帖子(404页)。我已经在google上搜索了这个问题,并应用了我搜索到的所有建议,但仍然没有任何帮助。问题是什么?