Pagination not working for Custom search form & custom result template

I am using custom search form and custom template to display the results according to the solution given in here
Everything is working perfect except the pagination which doesn’t seem to work at all


  • Custom post type : job_listing
  • Custom taxonomy : job_listing_type
  • custom fields as key: _job_location

Here is the code for search form :

<form method="get" id="advanced-searchform" role="search" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    <input type="hidden" name="search" value="advanced">

        <select id="my-select1" class="js-example-basic-single isotopeselect" data-filter-group="proyectos" multiple="multiple" name="terms[]">

        <?php foreach ($job_terms as $job_term): ?>
          <option value=".<?php echo str_replace(' ', '-', str_replace('&', 'and', html_entity_decode($job_term)));?>"><?php echo $job_term;?></option>
        <?php endforeach; ?>

        <button type="submit"><span>search</span></button>
    <input type="hidden" name="job_listing" value=""/>

Here is the search result template


    foreach ($myterms as $myterm) {

if($post_type =='job_listing'):
    $tax_query[] =  array(
                        'taxonomy' => 'job_listing_type',
                        'field' => 'name',
                        'terms' => $terms
                      ) );

$post_type = 'job_listing';
$paged= (get_query_var('paged' )) ? get_query_var('paged'):1;
$args         =  array(
    'tax_query' => $tax_query,
$loop = new WP_Query( $args );     

    <div class="my-services">


<?php endif; ?>
    <div class="pagination" id="blog-pagination">
      <span class="previous" ><?php previous_posts_link( '&larr;Newer', $loop->max_num_pages  ); ?></span>
      <span class="next"><?php next_posts_link( 'Older &rarr;', $loop->max_num_pages  ); ?></span>
    <?php wp_reset_query();?>     

<?php get_footer(); ?>

Result on initial search, url is like

After i hit next then url becomes

but nothing happens, result remains same

I have never done this before so please help me out on this

Read more here: Pagination not working for Custom search form & custom result template

Leave a Reply

Your email address will not be published. Required fields are marked *