Hi I have created my index.php file as a blog template and on my website I am creating a page using that template.The problem is that by doing it this way pagination is not working anymore.It worked when index.php was my home page.This is my code:

$index_query = new WP_Query(array(
                             if($index_query->have_posts()): while($index_query->have_posts()): $index_query->the_post();?>
                                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                    <h3><span>Posted on <span> <?php echo get_the_date(); ?> in <?php the_category(); ?> by <?php the_author_link(); ?></h3>
                                    <a href="<?php the_permalink(); ?>" class="box">
                                            if(function_exists('has_post_thumbnail') && has_post_thumbnail()){
                                        <span><?php comments_number("0") ?></span>
                                    <?php the_excerpt(); ?>
                                    <a href="<?php the_permalink(); ?>" class="read">Continue Reading</a>
                           <?php endwhile; endif;?>

   global $wp_query;
                        $total_pages = $wp_query->max_num_pages;

                        if($total_pages > 1){
                            $current_page = max(1 , get_query_var('paged'));
                            echo paginate_links(array(
                                'base' => get_pagenum_link(1) . '%_%',
                                'format' => '/page/%#%',
                                'current' => $current_page,
                                'total' => $total_pages

How can I make pagination work on page templates?

  • 2
    Try using query_posts() instead of WP_Query and pass the paged parameter too. Aug 24, 2012 at 8:48

1 Answer 1


Try add the "page" var to the WP_Query statement

$index_query = new WP_Query(array(
'paged'=>max(1 , get_query_var('paged')),

Is it the loop that is not paging through the posts, (it just displays the same ones no matter what page you are on? Or is the actual pagination just not displaying any links?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.