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
1 month
0 Answers
6 views
0
Leave an answer
You must login or register to add a new answer .