Post count for category and tag

Don’t run a custom query to get the post count. This is already done by the main query. What you are doing is the same as eating the same piece of meat twice. 🙂

As said, the main query already return the amount of posts found via the $found_posts property. You can access and display it anywhere on a page as follows

echo $wp_query->found_posts;

This will print the amount of posts that the main query found that mathes the URL request.

You can use the following on any page in your site, just change the text as needed

<?php 
    /* Search Count */ 
    $count = $wp_query->found_posts; 
    $text="<span class="resultsFound">";
if ( $count  <= 0 ) {
    $text .= sprintf(__( '( Nothing Found )' ), $count );
}

elseif ( $count <= 1 ) {
    $text .= sprintf(__( '( We found %d company )' ), $count );
} 

else {
    $text .= sprintf(__( '( We found %d companies )' ), $count );
}       
$text .= '</span>'; 
echo $text;
?>