Get total posts found, but while using limit for pagination? get_posts

You can use WP_Query instead of get_posts and then you can use the properties which are set for you:

  • $post_count – The number of posts being displayed.
  • $found_posts -The total number of posts found matching the current query parameters
  • $max_num_pages – The total number of pages. Is the result of $found_posts / $posts_per_page