I have a question.
How can I count number of posts of a tag ?
Example : Tag photos (67)
Thanks
Join Stack Overflow to learn, share knowledge, and build your career.
Use the code below:
$taxonomy = "category"; // can be category, post_tag, or custom taxonomy name
// Using Term Slug
$term_slug = 'some-category';
$term = get_term_by('slug', $term_slug, $taxonomy);
// Fetch the count
echo $term->count;
get_term_by('name', $term_name, $taxonomy);
or get_term_by('id', $term_id, $taxonomy);
instead of slug
– Shady Mohamed Sherif
Mar 20 '19 at 23:48