Count tags for a specific category

Question

So I have a simple code that gets the tags and counts them. How would I limit this code to a specific category? To only look at "category-name", and do the count there.

$terms = get_terms( array(
'taxonomy' => 'post_tag',
'hide_empty' => true,
'orderby' => 'ID',
    ) );
foreach($terms as $t) {
echo  '<div class="btn btn-info btn-sm ml-2">' .$t->name. ' <span class="badge badge-light">' .$t->count. '</span>
</div>';
}
0
Dan 8 months 2020-12-05T05:10:27-05:00 0 Answers 6 views 0

Leave an answer

Browse
Browse