title: Pagination in custom archive.php page
body: <p>I have created a custom <code>archive.php</code> page by adding some extra code to the default <code>archive.php</code>. I want to do pagination in that page but I don't know why it is not working.</p>
  
  <p>I use <code>wp-pagenavi</code> plugin for pagination. It shows the <code>page not found</code> error when I click on the 2nd page. To be more understandable I am posting an image of what is happening.</p>
  
  <p>The image below is what happens when the page loads. You can see the site address which I have marked in red:
  <img src="https://i.stack.imgur.com/X0ZHX.jpg" alt="enter image description here"></p>
  
  <p>Next is the image of what happens when I click on '2' to navigate to the 2nd page. As you can see the URL is <code>../?m=201303&amp;paged=2</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/CuCr5.jpg" alt="enter image description here"></p>
  
  <p>Below is the code I use for the custom archive page:</p>
  
  <pre><code>&lt;?php
  
  get_header(); ?&gt;
  
  &lt;div class="archive_page"&gt;
  
  &lt;?php 
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $args = array_merge( $wp_query-&gt;query, 
          array( 'cat' =&gt;'-1,-8,-9',
          'posts_per_page'=&gt;'2',
          'paged' =&gt;$paged));
        query_posts( $args );
       ?&gt;
  &lt;?php if ( have_posts() ) : ?&gt;
  
   &lt;header class="page-header"&gt;
   &lt;h1 class="page-title"&gt;
   &lt;?php if ( is_day() ) : ?&gt;
   &lt;?php printf( __( 'Daily Archives: %s', 'twentyeleven' ), '&lt;span&gt;' . get_the_date() . '&lt;/span&gt;' ); ?&gt;
  &lt;?php elseif ( is_month() ) : ?&gt;
  &lt;?php printf( __( 'Monthly Archives: %s', 'twentyeleven' ), '&lt;span&gt;' . get_the_date( _x( 'F Y', 'monthly archives date format', 'twentyeleven' ) ) . '&lt;/span&gt;' ); ?&gt;
      &lt;?php elseif ( is_year() ) : ?&gt;
  &lt;?php printf( __( 'Yearly Archives: %s', 'twentyeleven' ), '&lt;span&gt;' . get_the_date( _x( 'Y', 'yearly archives date format', 'twentyeleven' ) ) . '&lt;/span&gt;' ); ?&gt;
  &lt;?php else : ?&gt;
  &lt;?php _e( 'Blog Archives', 'twentyeleven' ); ?&gt;
      &lt;?php endif; ?&gt;
  &lt;/h1&gt;
      &lt;/header&gt;
  &lt;div id="navig"&gt;
      &lt;?php if (function_exists('wp_pagenavi')){wp_pagenavi();}?&gt;
  &lt;/div&gt;
  &lt;?php while ( have_posts() ) : the_post(); ?&gt;
  &lt;div id="all_posts"&gt;
      &lt;div id="auth_ava"&gt;
      &lt;?php echo get_avatar( get_the_author_email(), '65');?&gt;
      &lt;/div&gt;
      &lt;div class="post_title_archive"&gt;
      &lt;?php 
      the_title();
      ?&gt;
      &lt;/div&gt;
         &lt;div id="name_date_coment_tag"&gt;
             &lt;div id="auth_dis_name"&gt;
          &lt;?php the_author_posts_link();?&gt;
         &lt;/div&gt;
      &lt;div class="border"&gt;|&lt;/div&gt;
      &lt;div id="posted_date_archive"&gt;
          &lt;?php 
          the_time('F j, Y');
           ?&gt; 
      &lt;/div&gt;
      &lt;div class="border"&gt;|&lt;/div&gt;
      &lt;div class="categories"&gt;
          Categories: &lt;?php the_category(', '); ?&gt; 
      &lt;/div&gt;
      &lt;div class="border"&gt;|&lt;/div&gt;
      &lt;div id="tags_archive"&gt;
          &lt;?php 
              the_tags('Tags: ', ', ', '&lt;br /&gt;'); 
          ?&gt; 
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
          &lt;div class="excerpt_archive"&gt;
      &lt;?php 
          the_excerpt();
      ?&gt;
      &lt;/div&gt;
      &lt;?php endwhile; ?&gt;
      &lt;div id="navig"&gt;
         &lt;?php if (function_exists('wp_pagenavi')){wp_pagenavi();}?&gt;
      &lt;/div&gt;
      &lt;?php else : ?&gt;
      &lt;article id="post-0" class="post no-results not-found"&gt;
          &lt;header class="entry-header"&gt;
      &lt;h1 class="entry-title"&gt;&lt;?php _e( 'Nothing Found', 'twentyeleven' ); ?&gt;&lt;/h1&gt;
      &lt;/header&gt;
      &lt;div class="entry-content"&gt;
           &lt;p&gt;&lt;?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?&gt;&lt;/p&gt;
          &lt;?php get_search_form(); ?&gt;
          &lt;/div&gt;
      &lt;/article&gt;
          &lt;?php endif; ?&gt;
      &lt;/div&gt;
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>I am really sorry for a long question. I hope it is clear what I want to achieve.</p>