是否不能在filve.php上分页?

时间:2019-06-06 作者:M.T

我的分页无法用于存档。php,我正在使用它作为博客文章类别链接的模板。

<div class="row">
            <?php $the_query = new WP_Query( array(
                \'posts_per_page\'=>1,
                \'order\'=>\'DESC\',
                \'paged\' => get_query_var(\'paged\') ? get_query_var(\'paged\') : 1) 
            ); ?>

            <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
                <div class="col-lg-4 col-md-4 col-sm-12 blog-content text-styles">
                    <a class="blog-post-area" href="<?php the_permalink() ?>">
                        <?php if ( has_post_thumbnail() ) { 
                            the_post_thumbnail(\'main-news-thumbnail-uncropped\', array(\'class\' => \'img-fluid post-image\'));
                        } ?> 
                        <h3 class="post-title"><?php the_title() ?></h3>
                        <?php the_excerpt() ?>
                        <a class="blog-post" href="<?php the_permalink() ?>">Read More</a>
                    </a><!--End Link-->
                </div><!--End Columns-->
            <?php endwhile; ?>
        </div><!--End Row-->

        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12">
                <div class="pagination">
                    <?php 
                        $big = 999999999; // need an unlikely integer?>
                        <?php echo paginate_links( array(
                            \'base\' => str_replace( $big, \'%#%\', get_pagenum_link( $big ) ),
                            \'format\' => \'?paged=%#%\',
                            \'current\' => max( 1, get_query_var(\'paged\') ),
                            \'total\' => $the_query->max_num_pages
                        ) );
                    ?>
                    <?php wp_reset_postdata();?>
                </div><!--End Pagination-->
            </div><!--End Columns--->
        </div><!--End Row-->
有什么想法吗?我想不出来!

1 个回复
SO网友:MikeNGarrett

你在打电话wp_reset_postdata() 两次一次是在呼叫之前paginate_links().

相关推荐

如何为class-wp-query.php追踪这些PHP通知和警告的原因?

我的WordPress调试。日志文件中充满了这些PHP通知,间隔大约15分钟,然后是几个小时…[23-Mar-2018 05:33:00 UTC] PHP Notice: Trying to get property of non-object in /home/mysite/public_html/wp-includes/class-wp-query.php on line 3736 [23-Mar-2018 05:33:00 UTC] PHP Notice: Trying to get p