title: Wordpress Pagination - Too many pages for number of posts
body: <p>I've added pagination for a custom post type within my Wordpress theme. It works great, apart from it shows too many pages in the pagination menu for the number of posts: <a href="http://www.electrickiwi.co.uk/testimonials/" rel="nofollow">http://www.electrickiwi.co.uk/testimonials/</a></p>
  
  <p>There should currently be 7 pages, but it's showing 12. The code below is what I am using to display the pagination. There is nothing in the functions.php file relating to this.</p>
  
  <pre><code>&lt;?php
  /* ------------------------------------------------------------------*/
  /* PAGINATION */
  /* ------------------------------------------------------------------*/
  
  //paste this where the pagination must appear
  
  global $wp_query;
  $total = $wp_query-&gt;max_num_pages;
  // only bother with the rest if we have more than 1 page!
  if ($total &gt; 1) {
      // get the current page
      if (!$current_page = get_query_var('paged')) {
          $current_page = 1;
      }
      // structure of "format" depends on whether we're using pretty permalinks
      if (get_option('permalink_structure')) {
          $format = 'page/%#%/';
      }
      else {
          $format = 'page/%#%/';
      }
      echo paginate_links(array(
          'base' =&gt; get_pagenum_link(1) . '%_%',
          'format' =&gt; $format,
          'current' =&gt; $current_page,
          'total' =&gt; $total,
          'mid_size' =&gt; 4,
          'type' =&gt; 'list'
      ));
  }
  ?&gt;
  </code></pre>