我一直在调试这个,但似乎找不到问题所在。多看一眼会有帮助的!我正在尝试在我的博客帖子上添加分页。这是代码
在…上home.php
<?php
$total_pages = $wp_query->max_num_pages;
if ( $total_pages > 1 ) : ?>
<div class="pagination col-12 text-center mt-3">
<?php the_posts_navigation(); ?>
</div>
<?php endif; ?>
和上
template-tags.php
if ( ! function_exists( \'the_posts_navigation\' ) ) :
function the_posts_navigation() {
global $wp_query;
echo paginate_links( array(
\'base\' => get_permalink() . \'page/%#%\' . \'/\', \'format\' => \'?paged=%#%\',
\'format\' => \'?paged=%#%\',
\'current\' => max( 1, get_query_var(\'paged\') ),
\'total\' => $wp_query->max_num_pages,
\'prev_text\' => return_svg( \'arrow-left\' ),
\'next_text\' => return_svg( \'arrow-right\' ),
) );
}
endif;
你知道怎么回事吗?非常感谢!