分頁在 Wordpress 博客中不起作用。我已經跟蹤到 home.php 的具體負責文件。原始博客頁面可以正常顯示帖子(一次 10 個),但是如上所述分頁不起作用。<?php/**Category Page*/get_header(); ?><div class="container-fluid blogs post-section" id="blogs"><div class="container"><div class="row"><div class="col-sm-12 col-md-9 col-lg-8"><?php echo category_description( $category_id ); ?> <div class="category-posts"><?php$args = array( "post_type" => "post", "post_status" => "publish", "posts_per_page" => "10", "orderby" => "date", "order" => "DESC");$query = new WP_Query($args);if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?><div class="col-sm-12"><div class="inner-post"><?php if ( has_post_thumbnail() ) { ?><div class="thumbnail col-sm-4" style="background:none!important;"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div><?php } ?><div class="abso custom_abso col-sm-8"><div class="inner-box"><div class="date"><?php $archive_year = get_the_time('Y'); $archive_month = get_the_time('M'); $archive_day = get_the_time('d'); ?> <span class="month"><?php echo $archive_month; ?></span> <span class="day"><?php echo $archive_day; ?>,</span><span class="year"><?php echo $archive_year; ?></span></div><h2 style="margin-top:0;"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2><?php the_excerpt(); ?></div></div></div><p><a href="<?php the_permalink(); ?>" class="readmores">Read More <i class="fa fa-caret-right" aria-hidden="true"></i></a></p></div><?php endwhile; endif; ?></div><div class="pagination text-center"><?php the_posts_pagination( array( 'mid_size' => 2 ) ); ?></div><?php wp_reset_query(); ?></div><?php get_sidebar(); ?></div></div></div><?php get_footer(); ?>這很有效,因為分頁按鈕可以工作,但是,每頁只顯示一篇文章:關于如何每頁顯示 10 個帖子的任何建議?
1 回答

白豬掌柜的
TA貢獻1893條經驗 獲得超10個贊
請添加以下參數“分頁”。它設置分頁查詢變量。分頁是根據這個參數工作的。
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1)
到$args
.
- 1 回答
- 0 關注
- 152 瀏覽
添加回答
舉報
0/150
提交
取消