title: Wordpress: Search results pagination still not working
body: <p>I've searched high and low for solutions and tried different ones, including the one thoroughly explained <a href="https://wordpress.stackexchange.com/questions/120407/how-to-fix-pagination-for-custom-loops">here</a> by Chip Bennett, but I still can't seem to get it working. </p>
  
  <p>The first page of results work fine, but from page 2 it only shows the index template and still says page not found. Here's my code:</p>
  
  <p><strong>Functions.php</strong></p>
  
  <pre><code>function advanced_search_query($query) {
      if ($query-&gt;is_search) {
          $query-&gt;set('s', $_GET['s']);
          $query-&gt;set('post_type', array( 'properties' ));
          $query-&gt;set('meta_key', $_GET['meta_key']);
          $query-&gt;set('orderby', $_GET['sortby']);
          $query-&gt;set('order', $_GET['order']);
          $query-&gt;set('posts_per_page', '5');
          $query-&gt;set('paged', $paged);
  
          if (isset($_GET['author'])) {
              $query-&gt;set('author', $_GET['author']);
          }
  
          if (isset($_GET['propertytype'])) {
              $query-&gt;set('taxonomy', 'propertytype');
              $query-&gt;set('terms', $_GET['propertytype']);
          }
  
          $minCost = $_GET['minCost'];
          $minCost = preg_replace("/[^0-9]/","", $minCost);
          if ($minCost == ""){
              $minCost = "0";
          }
  
          $maxCost = $_GET['maxCost'];
          $maxCost = preg_replace("/[^0-9]/","", $maxCost);
          if ($maxCost == ""){
              $maxCost = "99999999999999";
          }
  
          $query-&gt;set('meta_query', array(
              'relation' =&gt; 'AND',
              array(
                  'key' =&gt; 'ce_location',
                  'value' =&gt; $_GET['location'],
                  'compare' =&gt; 'LIKE',
                  'type' =&gt; 'CHAR'
              ),
              array(
                  'key' =&gt; 'ce_cost',
                  'value' =&gt; array($minCost, $maxCost),
                  'compare' =&gt; 'BETWEEN',
                  'type' =&gt; 'NUMERIC'
              ),
              array(
                  'key' =&gt; 'ce_bedrooms',
                  'value' =&gt; array($_GET['minBedrooms'], $_GET['maxBedrooms']),
                  'compare' =&gt; 'BETWEEN',
                  'type' =&gt; 'NUMERIC'
              ),
              array(
                  'key' =&gt; 'ce_tenancy',
                  'value' =&gt; $_GET['tenancy'],
                  'compare' =&gt; 'LIKE',
                  'type' =&gt; 'CHAR'
              )
          ));
      };
      return $query;
  };
  add_filter('pre_get_posts', 'advanced_search_query', 1000);
  </code></pre>
  
  <p><strong>Code to pull query arguments</strong></p>
  
  <pre><code>global $query_string;
  
  $query_args = explode("&amp;", $query_string);
  $search_query = array();
  
  foreach($query_args as $key =&gt; $string) {
      $query_split = explode("=", $string);
      $search_query[$query_split[0]] = urldecode($query_split[1]);
  }
  $search_query['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
  
  $search = new WP_Query($search_query);
  </code></pre>
  
  <p><strong>Loop code:</strong></p>
  
  <pre><code>if ( have_posts() ) :  while (have_posts()) : the_post();
  
      //loop content
  
  endwhile;
      if(function_exists('wp_simple_pagination')) { wp_simple_pagination(); } ?&gt;
  else :
      echo 'Sorry, there are currently no property listings available';
  endif;
  </code></pre>
  
  <p>Any suggestions will be immensely appreciated.</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I also noticed the URL is modified when I try to access page 2.</p>
  
  <p>This is the page 1 URL:</p>
  
  <pre><code>http://localhost/cunningham/?location=&amp;propertytype=&amp;minBedrooms=1&amp;maxBedrooms=9&amp;minCost=0&amp;maxCost=100000&amp;meta_key=&amp;tenancy=&amp;s=
  </code></pre>
  
  <p>The page 2 URL:</p>
  
  <pre><code>http://localhost/cunningham/page/2/?location&amp;propertytype&amp;minBedrooms=1&amp;maxBedrooms=9&amp;minCost=0&amp;maxCost=100000&amp;meta_key&amp;tenancy&amp;s/
  </code></pre>