第 2 页未找到 (404) WordPress 分页


Page 2 not found (404) Wordpress Pagination

我正在localhost中测试WordPress,发布文章以查看工作原理,一切都很好,直到我必须在一页中写很多文章,我不得不使用分页转到第二页,好吧,我点击了第二页,但我得到了一个404未找到页面。

我找了大约 2-3 个小时,尝试了每个功能,每个示例,但结果是一样的。

主页是静态首页,称为登陆,所有文章都设置为博客页面。

我的 php 代码来自索引.php:

<div class="container-medium">
    <div class="row">

        <?php while(have_posts()) : the_post(); ?>
        <div class="col-xs-12 col-sm-12 col-md-12">
            <?php the_post_thumbnail('post-thumbnail', array( 'class'   => "img-responsive desaturate attachment-post-thumbnail")); ?> 
            <h3 class="blog-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
            <div class="row">
                <div class="col-sm-12"><p class="blog-post-text"><?php echo get_excerpt(); ?></p></div>
                <div class="col-sm-12"><a class="btn btn-sm btn-readmore" href="<?php echo get_permalink(); ?>">Read more <i class="icon-right-open"></i></a></div>
            </div>
        <hr class="dotted">
    </div>

    <?php endwhile; wp_reset_query(); ?>
    </div> <!-- end .row -->
            <?php if ( have_posts() ) : ?>
    <!-- Add the pagination functions here. -->
    <!-- Start of the main loop. -->
    <?php while ( have_posts() ) : the_post();  ?>
    <!-- the rest of your theme's main loop -->
    <?php endwhile; ?>
    <!-- End of the main loop -->
    <!-- Add the pagination functions here. -->
    <div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
    <div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
    <?php else : ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
</div> <!-- end .container-medium -->

读了一堆类似的问题,但我没有得到我想要的结果。

谢谢!

PS:PHP初学者

在循环中写这个

<?php

    $post_query = query_posts(array(
    'post_type'      => 'cover', // You can add a custom post type if you like
    'paged'          => get_query_var('paged', 1),
    'posts_per_page' => 1
));
?>

在底部

  <?php
  global $wp_query;
  $big = 999999999; // need an unlikely integer
  echo paginate_links( array(
       'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
       'format' => '?paged=%#%',
       'current' => max( 1, get_query_var('paged') ),
       'total' => $wp_query->max_num_pages
   ) );
  ?>