I want to print total number of posts filtered by its category. for example if there are 3 posts in category "abc" and 5 posts in category "xyz". when i am in any post of category "abc" then it should display 3 and if i am in any post of category "xyz" then it should print 5. Thanks
with this piece of code i am struggling to acheive these functionality
foreach((get_the_terms($post->ID, 'project_category')) as $term) {
echo $term->term_id. '';
}
above code will result the term id of current category. suppose the result is 7 then we put it in this code
$term = get_term( '7', 'category' );
$count = $term->count;
echo $count;
this will result total number of posts in current category . Now instead of hard coding '7' how can we achieve the result dynamically ?