WordPress numbered Pagination & updating the current page using query_posts

I can add numbered pagination to wordpress fine, the problem is when I click on page two the link for page one doesn’t appear to be clickable. The loop still thinks it’s on page one.

This is my current code.

<?php query_posts('posts_per_page=5'); ?>

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

 ....


<?php endwhile; 

endif; ?>

  <?php
global $wp_query;

$big = 999999999; // need an unlikely integer

 echo paginate_links( array(
 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big )         )  ),
 'format' => '?paged=%#%',
  'current' => max( 1, get_query_var('paged') ),
  'total' => $wp_query->max_num_pages
 ) );
 ?>

Related posts