分页仅适用于使用categories.php的博客?

分页仅适用于使用categories.php的博客?,php,wordpress,pagination,Php,Wordpress,Pagination,我已经为我的博客页面制作了一个模板,可以在最近的所有博客中调用,每个页面显示2个博客。我在循环中添加了一个分页函数,但它只是一遍又一遍地调用同一个页面,并显示相同的2个博客摘要,即使url为/blog/page/2。但是,当我在类别存档中打开的博客中单击分页链接时,分页工作并显示接下来的两个博客?请帮忙 博客页面模板: <?php /* * Template Name: Blog Homepage */ get_header()?> <main role

我已经为我的博客页面制作了一个模板,可以在最近的所有博客中调用,每个页面显示2个博客。我在循环中添加了一个分页函数,但它只是一遍又一遍地调用同一个页面,并显示相同的2个博客摘要,即使url为/blog/page/2。但是,当我在类别存档中打开的博客中单击分页链接时,分页工作并显示接下来的两个博客?请帮忙

博客页面模板:

 <?php 

 /*
  *   Template Name: Blog Homepage
 */

get_header()?>
  <main role="main">
    <section>
        <div id="bp-column-L">
        <h1>Our Most Recent Blogs</h1>
        <?php query_posts("posts_per_page=2"); ?>
         <?php get_template_part('loop'); ?>

        </div>

        <?php get_sidebar(); ?>

    </section>
</main>             

</div>

<?php get_footer()?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>

        <!--article-->
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

                <!-- post thumbnail -->
                <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                <?php the_post_thumbnail(array(120,120)); // Declare pixel size you need inside the array ?>
                        </a>
                <?php endif; ?>
                <!-- /post thumbnail -->

                <!-- post title -->
                <h2>
                        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
                </h2>
                <!-- /post title -->

                <!-- post details -->
                <span class="date"><?php the_time('F j, Y'); ?> <?php the_time('g:i a'); ?></span>
                <span class="author"><?php _e( 'Published by', 'html5blank' ); ?> <?php the_author_posts_link(); ?></span>
                <span class="comments"><?php if (comments_open( get_the_ID() ) ) comments_popup_link( __( 'Leave your thoughts', 'html5blank' ), __( '1 Comment', 'html5blank' ), __( '% Comments', 'html5blank' )); ?></span>
                <!-- /post details -->

                <?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>

                <?php edit_post_link(); ?>

        </article>


                        <!-- /article -->

<?php endwhile; ?>

        <?php get_template_part('pagination'); ?>
<?php else: ?>

        <!-- article -->
        <article>
                <h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
        </article>
        <!-- /article -->

<?php endif; ?>
function html5wp_pagination()
{
    global $wp_query;
$big = 999999999;
echo paginate_links(array(
    'base' => str_replace($big, '%#%', get_pagenum_link($big)),
    'format' => '?paged=%#%',
    'current' => max(1, get_query_var('paged')),
    'total' => $wp_query->max_num_pages
));
}