Wordpress: Number of posts excluding unclassified

Using this code, I can easily get the total number of messages:

$post_count = count_user_posts();
echo $post_count;

But I need the total to not include messages that are not classified.

+4
source share
1 answer

Use the following code and see the output:

$args = array('posts_per_page' => -1,'category' => '-1',);
$posts_array = get_posts( $args );
echo count($posts_array);

By default, the category identifier uncategorizedis 1.

+4
source

All Articles