Do your posts have multiple categories? If not – I think individual category counts are cached, so can sum up counts:
$categories = get_categories( array( 'exclude' => $folio_cat_ids ) );
$count = 0;
foreach ( $categories as $category)
$count += $category->category_count;
Can also just get and count the posts, that is more flexible and takes care of overlap, but also more resource-intensive:
$posts = get_posts( array(
'category__not_in' => $folio_cat_ids,
'numberposts' => '-1'
) );
$count = count( $posts );
Related Posts:
- How to Get All Posts with any post status?
- How can i get count from query post
- query_post by title?
- How to set posts per page using WP_Query()
- query_posts() in function makes global $wp_query out of sync?
- Problem with ‘post__not_in’
- Sort posts alphabetically by custom field value, insert divider between different letters
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- Custom Post Type “Event”: chronological list of recurring events
- Order posts using a custom array
- Tricky WP Query
- WordPress pagination showing same posts on each page
- Search breaks when querying main loop for category
- Using ajax with paging and a custom sub-query
- Custom loops, sticky posts, and pagination nightmare
- odd behaviours from template tags
- Having an issue doing a WP_Query with post_content and category__and
- Custom query looking at multiple custom fields and properly sorting
- Pre-existing arguments when using queries
- How to refine WP-Query with further criteria
- Run second query on page based on author of the first query
- Query Posts (post meta)
- posts_per_page no limit
- Query posts: how to exclude results if post is in multiple categories
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- WP 5.8 “Query Loop” block: where to place custom query?
- Meta Query with date and time on the same Day before given time
- order post my meta value m/d/y format with year as included value
- _wp_page_template to dynamically use template
- How to get the parent’s taxonomy?
- Schedule Sticky Posts
- WordPress Search Filter Only for Page with Child of Child of Child of Child of Child
- How to modify the query to exclude posts by slug?
- Multiple search queries on one page
- How add a custom posttype name using ACF field to a query post array
- Page navigation doesn’t show when query category
- post_status => publish not working
- 2 loops on page – one with orderby rand second orderby date
- How to fetch all posts in a category that were published between two given dates?
- get_meta_data within a loop
- how to exclude “featured” posts from the main loop?
- Slow WP_query due to nested wp_query. Need Suggestions
- Five posts from a category in footer
- pass query string on url to filter media
- Order posts by condition
- Co-authors plus problems with query_post
- Error sending array of inputs
- How to display multiple custom fields with the same meta_key in an ascending order?
- How to exclude latest x posts from a paginated query?
- How to exclude post formats from wordpress recent posts in a tabs widget [closed]
- Adding conditional content to single post-type template
- How to increase load time of an archive/search page (WP_Query)
- Query posts by meta_key whose value is an array
- Query Posts by Custom Field
- How to make WP_Query not to show irrelevant posts?
- Easy way to write complex queries in wordpress
- get_posts output always same post
- why the same code got different results when using query_posts in functions.php and index.php
- Pagination on category.php and tag.php not working
- Currently using a query_posts() in my theme – want to use a request filter in stead
- change the default order of posts only for specific categories
- WP_Query: Show 10 posts in date order, first three random
- Random posts that always include a particular post?
- Get next/prev image/attachment in time with date query
- Order for custom field after the loop
- Custom post query error
- Why doesn’t my WP Meta Query return any results?
- Multiple instances of query_posts
- If Query Post Returns 1 Post
- Change content off every sixth element
- Keeping get_posts’ offset and is_paged() synchronized
- Custom Post Type Query W/Category Dropdown
- How to get any type posts include attachments by ids?
- Create a Loop with Posts Ordered by Most Recent Comments
- Optimising WP_Query with ACF Fields
- Filter products on category AND tag
- Show posts from two specific category in WP_Query
- How to create loop of posts except post ID defined via ACF field
- How do I stop the same post showing multiple times in a archive?
- Specifying image size used in template the_content
- query_posts() doesn’t seem to be called in my page
- Fetching $_POST from Page Template into functions.php
- WordPress custom post type
- Optimising specific Query with ACF meta objects
- Order posts by ACF checkbox
- query_posts with sorting on a custom datestamp
- Post per page not working
- Show previous month’s posts
- query_posts result differs from wp_query request result
- Query Posts by date range with fixed beginning and end
- Collect posts from last 48 hours
- How to go to tag archives using a form
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Custom query_posts() parameter
- How to modify this function to exclude also the post belonging to a specific category?
- How to exclude certain portfolios from a loop
- Sort posts with multiple meta_keys
- Create “archives by year and week” by category template
- query_posts different amount of posts per page [duplicate]
- Quering array of post types & pagination. Articles are repeating sometimes on different pages