title: pagination for custom post type archive page
body: <p>I'm trying to add pagination to following code inside archive-CustomPostType.php page but it doesn't show pagination or it shows empty page.
  My code:</p>
  
  <pre><code>   &lt;?php get_header(); ?&gt; 
   &lt;h2 class="ptm pbm mbl text-right red-bg"&gt;&lt;span&gt;سریال&lt;/span&gt;&lt;/h2&gt;
  
  &lt;div class="container"&gt;
  
   &lt;?php 
              $terms =  get_queried_object();
  
            $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
  
                 $posts = get_posts(array(
  
                   'post_type' =&gt; 'series',
                   'posts_per_page' =&gt; 20,
                   'paged' =&gt;$paged,
                    'category'   =&gt; $terms-&gt;term_id,
  
                   'meta_query' =&gt; array(
                       array(
                       'key' =&gt; 'is_season',
                       'compare' =&gt; '==',
                       'value' =&gt; '0'
                     )
                   )
  
                 ));
                 if( $posts ): ?&gt;
              &lt;ul&gt;
                 &lt;?php foreach( $posts as $post ): 
                    setup_postdata( $post )
  
                    ?&gt;
  
  
                &lt;!--HTML goes here--&gt;
  
  
  
                 &lt;?php endforeach; ?&gt;
              &lt;/ul&gt;
               &lt;div class="pagination"&gt;
          &lt;?php wp_pagenavi(); ?&gt; 
        &lt;/div&gt;
              &lt;?php wp_reset_postdata(); ?&gt;
              &lt;?php endif; 
                    ?&gt;
  
  &lt;/div&gt;
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>I'm using page navi for pagination but I don't think it's the problem because I tried with normal wordpress pagination but didn't help.</p>
  
  <p>I think the issue is coming from <code>get_queried_object</code> and I don't know how to handle this.</p>
  
  <p>Any help would be appreciated.</p>