I am using the plugin Ajax Load More to query posts and have a filter system to thin out the posts in the loop. I am trying to add a counter that will say "Your search returned X amount of posts" Where X is the number of posts displayed/matching the current criteria.

I was able to grab the total number of posts, but wasn't able to grab the current number of posts being displayed via Ajax Load More. Wasn't able to find much when I was searching for it.

Anyone have any idea how to display the number of current posts displayed using Ajax Load More and not the number of every post?

You can get the (current) displaying posts number from offset number.
As it's an ajax load more for wp post, it should has the offset numbers.
So, you can display the number like this

Javascript

var offset = 4;
return $.ajax({
        url: ajaxurl,
        type: "POST",
        data: data,
        success: function(returnData) {
        // diplay offset number in .post-number div
         $('div.post-number').html('This is the displaying post number = '+ offset);
        }

 }), offset += 4;

HTML

<div class="post-number"></div>

You can add this under the loadmore div


I am not quite sure with Ajax Load More plugin.

If you just want to customize Ajax Load More plugin, you should ask the author of that plugin.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.