wordpress - WP_Query Pagination not working properly -


so, have 'job' post type list. pagination list showing same list on over , over. stuck first 5 results , previous link. also, trying run shortcode on home page.

function my_job_by_location($atts, $content = null) {     if(! isset($atts['location']))         return '<p class="job-error">please set location</p>';          $atts = shortcode_atts(['title'         => 'jobs openings availible @ ',                                 'count'         => 5 ,                                 'location'      => '',                                 'pagination'    => 'on'                                 ], $atts);          $paged      = get_query_var('paged') ? get_query_var('paged') : 1;         $pagination = $atts[ 'pagination' ]  == 'on' ? false : true;          $args = [   'post_type'              => 'job',                     'post_status'            => 'publish',                     'no_found_rows'          => $pagination,                     'posts_per_page'         => $atts['count'],                     'paged'                  => $paged,                     'tax_query'              => ['taxonony' => 'location',                                                  'field'    => 'slug',                                                  'terms'    => $atts['location']                                                 ]                  ];          $wp_query = new wp_query($args);           $location = str_replace ('-', ' ', $atts['location']);         $title    = esc_html__($atts['title']);         $location = esc_html__($atts['location']);          if( $wp_query-> have_posts())         {             $output  = "<div id='job-location-list'>";             $output .= "<h4>".$title."  " .$location." </h4> <ul>";              while ($wp_query-> have_posts()) : $wp_query-> the_post();              global $post;              $deadline   = esc_html__(get_post_meta( get_the_id() , 'deadline', true ));             $title      = get_the_title();             $url        = esc_url( get_permalink() );              $output .= "<li id='job-location'><a href='" .$url. "'>";             $output .= $title."</a>";             $output .= " // <span>".$deadline. "</span></li>";              endwhile;              $output .= "</ul> </div>";          }          wp_reset_postdata();         $max_pages = $wp_query->max_num_pages;          if($max_pages > 1 && is_page() )         {             $output .= "<nav class='prev-next-posts'>";              $output .= "<div class='nav-previous'>";             $output .= get_next_posts_link(__("<span class='meta-nav'>&larr;</span> previous"), $max_pages );             $output .= "</div>";              $output .= "<div class='next-post-links'>";             $output .= get_previous_posts_link(__("<span class='meta-nav'> &rarr; </span>next") );             $output .= "</div> </nav>";           }          return $output;  }  add_shortcode("job_by_location", "my_job_by_location"); 


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -