Javascript 使用此代码时如何在wordpress中添加分页?

Javascript 使用此代码时如何在wordpress中添加分页?,javascript,php,wordpress,custom-wordpress-pages,Javascript,Php,Wordpress,Custom Wordpress Pages,我正在使用此代码在我的主页上显示post循环 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); get_template_part( 'content', get_post_format() ); endwhile; endif; ?> 如果要查看上一页和下一页,请尝试以下操作: the_posts_pagination( array( 'm

我正在使用此代码在我的主页上显示post循环

<?php 

    if ( have_posts() ) : while ( have_posts() ) : the_post();

        get_template_part( 'content', get_post_format() );

    endwhile; 
    endif; 

?>

如果要查看上一页和下一页,请尝试以下操作:

the_posts_pagination( array(
    'mid_size'  => 2,
    'prev_text' => __( 'Back', 'textdomain' ),
    'next_text' => __( 'Onward', 'textdomain' ),
) );
或者,如果您希望没有上一页和下一页:

the_posts_pagination( array( 'mid_size'  => 2 ) );
endwhileendif之后

要设置每页的帖子,请转到setting>Reading并在“博客页面最多显示”字段中设置数字

这里是完整的分页参考:


希望对大家有用

帖子是否正确显示?编辑后我能看到你的代码吗?