Any way to get total posts count?
See original GitHub issueHello!
According to the official docs: https://developer.wordpress.org/rest-api/using-the-rest-api/pagination/
“To determine how many pages of data are available, the API returns two header fields with every paginated response: X-WP-Total: the total number of records in the collection X-WP-TotalPages: the total number of pages encompassing all available records”
I query posts using await client.Posts.Query(query)
, with ‘Page’ and ‘PerPage’ parameters set, but this method only returns posts. Is there a way to get total posts count without actually loading all of them with client.Posts.GetAll()
?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:7 (2 by maintainers)
Top Results From Across the Web
wp_count_posts() | Function - WordPress Developer Resources
The wp_count_posts() can be used to find the number for post statuses of any post type. This includes attachments or any post type...
Read more >Get post count of current loop when using multiple queries ...
There is another way that I use within the loop that counts posts using current_post + 1 , for example. <?php $my_query =...
Read more >WordPress get count of posts without using get_posts()?
$myCount = $wp_query->found_posts;. That will return the number of posts found for the last query. If you want to count the number of...
Read more >How to Show Total Number of Posts in WordPress
Now you can use the shortcode [total_posts] to display total number of posts in any posts, pages, or sidebar widgets. We hope this...
Read more >How to Display the Total Number of Posts on Your ...
On the left-hand admin panel, click on Settings and select the Simple Blog Stats option. click on Settings and select the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey, thanks so much for your work. I’ll try to check it out on the weekend!
My prototype: https://github.com/robertsundstrom/WordPressPCL/tree/queryresult
I created the QueryResult<T> class, and substituted the return type of Query (IEnumerable<T>) with it. It would not be a big deal since QueryResult<t> is implementing IEnumerable<T>.
The added properties of QueryResult<T> are Total and TotalPages.