Have a custom-taxonomy
called campaign_action
with three categories called draft
, live
and paused
.
I would like to display just the count for each but not in a list.
For example, I would like to echo the count for each individually as -
<li>Draft (<?php //code to display a number count for drafts ?>)</li>
<li>Live (<?php //code to display a number count for live ?>)</li>
<li>Paused (<?php //code to display a number count for paused ?>)</li>
I have successfully done this by displaying
foreach ( $terms as $term ) {
echo '(' . $term->count . ')';
}
However, this does not work for me and I want to get the $count
for each individually.
Thank you for your help.
EDIT
To show further what I have in place currently
<?php
$terms = get_terms('campaign_action');
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
echo '(0)';
foreach ( $terms as $term ) {
echo '(' . $term->count . ')';
}
}
?>
This will show all counts for each individual category but I only want to show the count for the category of draft
within the custom_taxonomy
of campaign_action
Here is an image of what the above achieves when added to the end of the Drafts. I want it to only show the count for the category of drafts
within the custom-taxonomy
of campaign_action
. If it has zero posts with that category then it should show zero.