title: Wordpress custom post pagination 404 error
body: <p>I've been looking around all day for an answer but no luck.</p>
  
  <p>I have made a custom post type so I can <strong>display posts</strong> on the page template but <strong>pagination is not working</strong> .<strong><em>I get a 404 error</em></strong>.</p>
  
  <p>Maybe some of you can guide me and tell me what is the problem.<strong>Here is the</strong> <a href="http://clintbronson.com/trestleboard/" rel="nofollow noreferrer">site</a>.</p>
  
  <p>Use this <em>password</em> <strong><em>broncosrule</em></strong>.
  Thank You.</p>
  
  <p>Here is the code .</p>
  
  <p>Custom page template:</p>
  
  <pre><code>&lt;?php
  /**
   * Template Name: Custom Page
   * The custom page template file
   */ 
  ?&gt;
  
  &lt;?php get_header(); ?&gt;
  
  
  
  &lt;?php 
  
    $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  
    $custom_args = array(
        'post_type' =&gt; 'trestleboard',
        'posts_per_page' =&gt; 1,
        'paged' =&gt; $paged
  
      );
  
    $custom_query = new WP_Query( $custom_args ); ?&gt;
  
    &lt;?php if ( $custom_query-&gt;have_posts() ) : ?&gt;
  
      &lt;!-- the loop --&gt;
      &lt;?php while ( $custom_query-&gt;have_posts() ) : $custom_query-&gt;the_post(); ?&gt;
        &lt;article class="loop"&gt;
          &lt;!--&lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;--&gt;
          &lt;div class="content"&gt;
            &lt;?php the_content(); ?&gt;
          &lt;/div&gt;
        &lt;/article&gt;
      &lt;?php endwhile; ?&gt;
      &lt;!-- end of the loop --&gt;
  
      &lt;!-- pagination here --&gt;
      &lt;?php
        if (function_exists(custom_pagination)) {
          custom_pagination($custom_query-&gt;max_num_pages,"",$paged);
        }
      ?&gt;
  
    &lt;?php wp_reset_postdata(); ?&gt;
  
    &lt;?php else:  ?&gt;
      &lt;p&gt;&lt;?php _e( 'Sorry, no posts matched your criteria.' ); ?&gt;&lt;/p&gt;
    &lt;?php endif; ?&gt;
  
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p><strong>Functions.php file</strong></p>
  
  <pre><code>// Our custom post type function
  function custom_pagination($numpages = '', $pagerange = '', $paged='') {
  
    if (empty($pagerange)) {
      $pagerange = 2;
    }
  
    /**
     * This first part of our function is a fallback
     * for custom pagination inside a regular loop that
     * uses the global $paged and global $wp_query variables.
     * 
     * It's good because we can now override default pagination
     * in our theme, and use this function in default queries
     * and custom queries.
     */
    global $paged;
    if (empty($paged)) {
      $paged = 1;
    }
    if ($numpages == '') {
      global $wp_query;
      $numpages = $wp_query-&gt;max_num_pages;
      if(!$numpages) {
          $numpages = 1;
      }
    }
  
    /** 
     * We construct the pagination arguments to enter into our paginate_links
     * function. 
     */
    $pagination_args = array(
      'base'            =&gt; get_pagenum_link(1) . '%_%',
      'format'          =&gt; 'page/%#%',
      'total'           =&gt; $numpages,
      'current'         =&gt; $paged,
      'show_all'        =&gt; False,
      'end_size'        =&gt; 1,
      'mid_size'        =&gt; $pagerange,
      'prev_next'       =&gt; True,
      'prev_text'       =&gt; __('&amp;laquo;'),
      'next_text'       =&gt; __('&amp;raquo;'),
      'type'            =&gt; 'plain',
      'add_args'        =&gt; false,
      'add_fragment'    =&gt; ''
    );
  
    $paginate_links = paginate_links($pagination_args);
  
    if ($paginate_links) {
      echo "&lt;nav class='custom-pagination'&gt;";
        echo "&lt;span class='page-numbers page-num'&gt;Page " . $paged . " of " . $numpages . "&lt;/span&gt; ";
        echo $paginate_links;
      echo "&lt;/nav&gt;";
    }
  
  }
  </code></pre>