title: Pagination on search results page with Custom Query not functioning (WordPress)
body: <p>I'm building currently a website on WordPress. The site has a custom post type. I have a customized search form, which selects entries from custom post type. Entries are being selected and sorted as they are supposed to, however on my search result page (job-search.php) I need a pagination, and it's not working, although same codes works fine on other pages. I see page number changing in browser's search bar, but I always see entries from first page.</p>
  
  <p>Code for search form and query for custom post type with specified selections and filtering (inside job-search.php):</p>
  
  <pre><code>&lt;?php
  /*
   * Template Name:job-search
   */
  get_header();?&gt;
  
  &lt;div&gt;
      &lt;form method="get" action="&lt;?php echo site_url('/'); ?&gt;/job-search" &gt;
          &lt;input type="search" name="job-name" placeholder="Job..." /&gt;
          &lt;input type="search" name="town-name" placeholder="Town..." /&gt;
          &lt;select type="search" name="date"&gt;
              &lt;option value="DESC"&gt;Datum absteigend&lt;/option&gt;
              &lt;option value="ASC"&gt;Datum aufsteigend&lt;/option&gt;      
          &lt;/select&gt;
          &lt;div&gt;
              &lt;input type="checkbox" name="cat[]" value="IT, Telekommunikation" /&gt;IT, Telekommunikation
              &lt;input type="checkbox" name="cat[]" value="Ingenieur, Technik" /&gt;Ingenieur, Technik
              &lt;input type="checkbox" name="cat[]" value="Handwerk, Gewerbe" /&gt;Handwerk, Gewerbe
          &lt;/div&gt;
          &lt;input type="submit" value="Search"&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;?php
      $jobName = $_GET['job-name'];
      $jobTown = $_GET['town-name'];
      $jobDate = $_GET['date'];
  
      if($_GET['cat'] &amp;&amp; !empty($_GET['cat'])){
          $jobCat = $_GET['cat'];
      }
      else{
          $jobCat = array('Vertrieb, Verkauf', 'IT, Telekommunikation', 'Ingenieur, Technik', 'Personalwesen', 'Bildung, Soziales', 'Einkauf, Logistik', 'Handwerk, Gewerbe', 'Führungskräfte', 'Marketing, PR', 'Medizin, Pflege', 'Finanzen, Steuern, Recht', 'Kaufmännische Berufe', 'Luft- und Raumfahrt, Reise', 'Ausbildung', '');
      }
  ?&gt;
  &lt;h1 style="font-size:1.5em; font-weight:bold; border-bottom:2px solid green; color:green; margin-bottom:20px;"&gt;wp_query_search results&lt;/h1&gt;
  &lt;?php
      $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
      $q1 = array(
          'post_type' =&gt; 'jobs',
          's' =&gt; $jobName,
          'posts_per_page' =&gt; 10,
          'paged' =&gt; $paged,
          'meta_key' =&gt; 'date',
          'orderby' =&gt; 'meta_value',
          'order' =&gt; $jobDate,
          'meta_query' =&gt; array (
              'relation' =&gt; 'AND',
              array(
                  'key' =&gt; 'town',
                  'value' =&gt; $jobTown,
                  'compare' =&gt; 'LIKE'
              ),
              array(
                  'relation' =&gt; 'OR',
                  array(
                      'key' =&gt; 'cat_1',
                      'value' =&gt; $jobCat
                  ),
                  array(
                      'key' =&gt; 'cat_2',
                      'value' =&gt; $jobCat
                  )
              )
          )
      );
      $query = new WP_Query($q1);
      if($query-&gt;have_posts()) : while($query-&gt;have_posts()) : $query-&gt;the_post();?&gt;
          &lt;h2 style="color:brown; font-weight:bold; border-bottom:1px dotted brown;"&gt;&lt;?php the_field('title'); ?&gt;&lt;/h2&gt;
          &lt;h3&gt;&lt;?php the_field('town'); ?&gt;&lt;/h3&gt;
          &lt;h4&gt;&lt;?php the_field('cat_1'); ?&gt; | &lt;?php the_field('cat_2'); ?&gt;&lt;/h4&gt;
          &lt;h5&gt;&lt;?php the_field('date'); ?&gt;&lt;/h5&gt;
      &lt;?php endwhile;
  
      if (function_exists(search_pagination)) {
          search_pagination($query-&gt;max_num_pages,"",$paged);
      }
  
      endif; wp_reset_query(); ?&gt;
  
  &lt;/div&gt;
  &lt;?php get_footer(); ?&gt;
  </code></pre>
  
  <p>Code for Pagination (inside functions.php):</p>
  
  <pre><code>function search_pagination($numpages = '', $pagerange = '', $paged='') {
    if (empty($pagerange)) {
      $pagerange = 2;
    }
    $paged;
    if (empty($paged)) {
      $paged = 1;
    }
    if ($numpages == '') {
      //global $wp_query;
      //$numpages = $wp_query-&gt;max_num_pages;
      $numpages = $query-&gt;max_num_pages;
      if(!$numpages) {
          $numpages = 1;
      } 
    }
    $pagination_args = array(
      'base'            =&gt; get_pagenum_link(1) . '%_%',
      'format'          =&gt; '/page/%#%',
      'total'           =&gt; $numpages,
      'current'         =&gt; $paged,
      'show_all'        =&gt; False,
      'end_size'        =&gt; 1,
      'mid_size'        =&gt; $pagerange,
      'prev_next'       =&gt; True,
      'prev_text'       =&gt; __('&amp;laquo;'),
      'next_text'       =&gt; __('&amp;raquo;'),
      'type'            =&gt; 'plain',
      'add_args'        =&gt; false,
      'add_fragment'    =&gt; ''
    );
  
    $paginate_links = paginate_links($pagination_args);
  
    if ($paginate_links) {
      echo "&lt;nav class='custom-pagination'&gt;";
        echo $paginate_links;
      echo "&lt;/nav&gt;";
    }
  }
  </code></pre>