If you want the total count of all the published posts in a particular category you can try this.
$all_posts = new WP_Query( array( 'posts_per_page' => -1, 'post_status' => 'publish', 'cat' => 3 ) );
echo $all_posts->post_count;
or
$all_posts = new WP_Query( array( 'posts_per_page' => -1, 'post_status' => 'publish', 'category_name' => 'uncategorized' ) );
echo $all_posts->post_count;
Just make sure to replace the ‘category_name’ or ‘cat’ with desired category.
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- Wp get all the sub pages of the parent using wp query
- Return only Count from a wp_query request?
- How to query for most viewed posts and show top 5
- WP_Query vs get_posts
- Query Custom Meta Value with Increment
- Get posts by meta data OR title
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- How to make an activities stream mixing posts and comments?
- Pass the same object to multiple widgets in a template with one query
- Retrieve or Query Pages by ID
- How do you query wordpress posts using a math formula between multiple meta field values?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Page navigation doesn’t show when query category
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- How to correctly pass values to wpdb->prepare()?
- How to query a custom post type with a taxonomy filter but display post type archive page?
- Change query_posts to WP_Query in page but does not work
- Iterating through $wpdb query without using get_results for large query results
- Slow page loads due to WordPress Core Query
- Query Page Content From Theme Options?
- How can I override one post and make it display content for another post?
- Include current post into loop
- WordPress query posts with multiple post_meta data
- Filter post query to only show direct children of category
- Should I reset $wp_query?
- Why doesn’t my WP Meta Query return any results?
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- Filter products on category AND tag
- Any way to use FETCH_KEY_PAIR with $wpdb?
- pre_user_query vs pre_get_posts
- Get posts that match defined arrays of tags
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- I need query_posts() to order results first by a meta value and then by post ID
- How to show post title in content editor in backend?
- My entry results are not consistently alphabetized
- Merge two queries and remove duplicate
- wpdb get_results() returns only 2 rows
- Ordering Posts by parent category, name ascending
- Optimising specific Query with ACF meta objects
- How to organize a WP_Query’s list of posts by category and display category title?
- When should you use WP_Query vs query_posts() vs get_posts()?
- How to query post ids liked by the Author
- WordPress Query showing multiple titles
- Query Posts by date range with fixed beginning and end
- custom query to get posts
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- how to use transient method?
- order by numeric value for meta value
- Some doubts about how the main query and the custom query works in this custom theme?
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- How do I create my own nested meta_query using posts_where / posts_join?
- Highlighting Sub topic in a post?
- how to retrieve specific product attribute value in an sql query?
- How to find out what “Blog pages show at most” is set to [duplicate]
- WordPress custom archive page
- How to do a query on custom taxonomies that is uncategorised?
- Empty tax_query array returns an empty array
- How do I search inside specific taxonomies in WordPress
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- What’s the purpose / logic of split_the_query in WP_Query->get_posts
- Setting get_queried_object
- remove query arg from url after set query
- difference between like ‘%%%var%%’ and ‘%var%’
- How to build a WP_Query using mulitple tags and using AND or OR operator between them
- Multiple loops without repeating content
- Sort query by author: 1 author, then others
- Bypass “supress_filters” in WP Query
- How to get list of posts from permalinks?
- Is there a reason why Pages are not publicly_queryable?
- Check return value of get_posts
- Exclude some authors from query
- Get a list of posts by specific category
- Conditional operator OR not working with custom fields
- How to add custom meta to ‘pre_get_terms’?
- Shortcode for custom query not returning results when attributes are added
- Posts query according to meta box date
- Max Posts and Memory Limit
- WP MS: How to query over the network
- Start Query from 2nd Post without offset
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- Query post and sort by custom value calculated with custom field on cpt
- duplicated posts when using pagination
- Problem with my loops
- How to query users by post count no less than 10
- WP_Query about meta_key and its array value
- Create global array to compare inside a query
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Modify query to exclude certain ids and certain parents and its corresponding children
- Filter posts/pages by user_role array
- Optimising amount of calls to custom fields
- Search Query that Includes Custom Table
- Custom post types loop on a page template
- Parsing External Table Arguments
- difference between methods of query
- wpdb LIKE request shows all database data
- Query posts by meta value and sort by another meta key
- Incorrect posts displayed on category page