title: Create pagination for custom post types in Wordpress
body: <p>I have an events page which I would like to add pagination to. However, with it being a custom post type I am finding it rather difficult. I have managed to get pagination working for my news page, but I cannot get the same result for the events page. Here is my code for the events page</p>
  
  <pre><code>&lt;?php
  get_header();
  get_sidebar('left');
  ?&gt;
  &lt;article class="content-main events" role="main" id="post-&lt;?php the_ID() ?&gt;"&gt;
  &lt;?php include 'breadcrumbs.php'; ?&gt;
  &lt;?php query_posts(array('posts_per_page'=&gt;'2')); ?&gt;
  &lt;?php while (have_posts()) : the_post(); ?&gt; 
          &lt;div class="news-post"&gt;
              &lt;h1&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title() ?&gt;&lt;/a&gt;&lt;/h1&gt;
              &lt;?php the_excerpt() ?&gt;
          &lt;/div&gt;
  
          &lt;?php endwhile; ?&gt;
          &lt;?php wp_reset_query(); ?&gt;
  
  &lt;!--Pagination--&gt;
      &lt;?php echo paginate_links( $args ) ?&gt;
      &lt;?php
      global $wp_query;
  
      $big = 999999999; // need an unlikely integer
  
      echo paginate_links( array(
          'base' =&gt; str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
          'format' =&gt; '?paged=%#%',
          'current' =&gt; max( 1, get_query_var('paged') ),
          'total' =&gt; $wp_query-&gt;max_num_pages
      ) );
      ?&gt;
  &lt;/article&gt;&lt;!-- //.content-main --&gt;
  &lt;?php
  
  get_footer();
  </code></pre>
  
  <p>If I try to change this </p>
  
  <pre><code>&lt;?php query_posts(array('posts_per_page'=&gt;'2')); ?&gt;
  </code></pre>
  
  <p>to this</p>
  
  <pre><code>&lt;?php query_posts(array('category_name'=&gt;'events','posts_per_page'=&gt;'2')); ?&gt;
  </code></pre>
  
  <p>This doesnt work either. However, if I remove the line altogether, it shows up the news post types. I am stumped!</p>