Site icon Hip-Hop Website Design and Development

Rely posts for pagination

I am doing the pagination for an internet. < Earlier (pagenumber) Subsequent > is straightforward, already performed. However now I would like so as to add a selector to go to a web page immediately (ex: to web page 7), to take action, I have to know what number of pages there are, and for this I have to rely what number of posts have been discovered within the question.

The issue is that this net has too many posts (> 13.000) and querying all of them slows down the web page loading, and it takes like… 10 seconds for the web page to load. Clearly this isn’t acceptable. Pagination solves that downside as a result of solely 50 or 100 posts are loaded at a time, however then I can not rely all of them.

Can I rely posts in a sure question with out loading them? Or can I get the variety of pages some other method?

I can not embrace ALL the code, as a result of it is too giant, however mainly, it is a shortcode and I do that:

$args = array();
$args['parameters...'] = worth;
$args['posts_per_page'] = 50;
$args['offset'] = 50 * web page;   <-- pagination offset
...
$posts = get_posts( $args );  <-- I need to rely this with out posts_per_page = 50

I attempted doing:
$rely = sizeof($posts);

And this works, but it surely takes too lengthy as a result of, moreover, I’ve to run the question twice: one with posts_per_page = -1 and one with posts_per_page = 50.