In wordpress website i get 200 plus post with Ajax post filter.

This is the Ajax post filter code:

PHP:

 // The query (compiled)
$query = new WP_Query( array(
  'post_type'       => 'POST',
  'meta_query'  => $meta_query
));

// The Loop
if( $query->have_posts() ) :
 while( $query->have_posts() ): $query->the_post();
    get_template_part('content');
endwhile;
   wp_reset_query();
else :
   _e('Sorry, no posts matched your criteria.');
   wp_send_json($query->posts);
endif;
   the_posts_pagination() ;
die(); 

Jquery:

jQuery(document).ready(function($){
  $('#test .br').click(function(){
  var choices = {};
  console.log(choices);

$.ajax({
    url: ajaxobject.ajaxurl,
    type :'POST',
    data : {
      'action' : 'call_post',
      'choices' : choices,
  },

success: function (result) {
    $('.filter-output').append(result);
  }     
 });
})
});

What is Solution for 200 plus post which get by Ajax? Pagination , Load more post button or else.

I post question here after waste a lot of time on work and Google search. But i have no solution.

Any help will be appreciated…

Read more here: How to paginate Ajax result


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: