0

I have in my pagination code below I have seemed to figured out how to omit the /page/1/ from the first link of my pagination like this 'base' => get_pagenum_link(1) . '%_%', on news posts and archive pages etc. But now on search queries http://url.com/?s=query the next pagination ends up like this ?s=querypage2 instead of /page/2/?s=query which was how it was previously.

How to get it on search queries it moves page/2/ before the query? Thanks

function vb_pagination( $query=null ) {
  global $wp_query;
  $query = $query ? $query : $wp_query;
  $big = 999999999;
   $paginate = paginate_links( array(
    //'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ),
    'base' => get_pagenum_link(1) . '%_%',
    'type' => 'array',
    'total' => $query->max_num_pages,
    'current' => max( 1, get_query_var('paged') ),
    'prev_text' => __('«'),
    'next_text' => __('»'),   
     )
  );
  if ($query->max_num_pages > 1) :
  ?>
  <nav>
  <ul class="pagination">
     <?php
     foreach ( $paginate as $page ){
          echo '<li>' . $page . '</li>';
     }
  ?>
  </ul>
  </nav>
  <?php
      endif;
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.