I've been searching for the right way to count all published posts but excluding specific categories. I know of the function wp_count_posts but it doesn't have the option to exclude specific categories. So I came up with the following:
You could also use get_posts() with the category__not_in parameter and then counting the number of returned posts but I'm not sure if it would be a faster/more efficient solution.
It works! But is that the correct way or is there some other way I'm missing?