In WordPress, how do I get the number of posts next to single_cat_title(”); in the category.php file?

I figured out how to do it.

This code shows the number of posts on a page after clicking on a category in WordPress. Even if the post has lots of categories.

<?php $category = get_queried_object(); echo $category->count; ?>

I used this code as the code was in the category.php file and not part of the regular loop.

I hope this code helps anyone else if they are having the same type of problem.