I have a problem with pagination on search results page. The page links appear, but when i click onto page 2, it gives me a 404 error.

search.php

<?php 
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                    $args = array( 'paged' => $paged );
                    $wp_query = new WP_Query($args);
                ?>
        <div>
         <?php  if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
        <div id="post-<?php the_ID(); ?>" <?php post_class('item'); ?>>
        <?php
       $featuredImage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
       if ( has_post_thumbnail() ) {
        echo '<a class="single-image link-icon" href="'.get_the_permalink().'">';
       echo '<img src="'.$featuredImage.'" style="width:213px; height:110px;" />';
        echo '</a>';
       }
       ?>
     <h6 class="title"><a href="<?php  the_permalink(); ?>"><span><?php  the_title(); ?></span></a></h6>
     <div class="entry-body">
      <?php wpe_excerpt('wpe_excerptlength_index', ''); ?>
      <a class="button default color" href="<?php  the_permalink(); ?>">Read More</a>
       </div><!--/ .entry-body-->
      </div><!--/ .item-->
    <?php  endwhile; ?>
    <div class="clear"></div>
    <div class="pagenavi clearfix">
    <!-- then the pagination links -->
    <?php next_posts_link( '← Older Posts' ); ?>
    <?php previous_posts_link( 'Newer Posts →' ); ?>
    </div>
    <?php  else : ?>
   <h1 class="title">Not Found</h1>
   <p>Sorry, but you are looking for something that isn't here.</p>
   <?php  endif; ?>
  </div>

Please suggest some solutions.

Read more here: WordPress pagination not working in search result page


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: