count posts with comman tags within specific category

i have two categories ‘A’ and ‘B’. Both have 5 posts(each) with tag ‘C’. How i can display the number of posts as 5 in Category ‘A’ or ‘B’ page. It showing total number of post with tag ‘C’ as 10. I need to show it as 5. How i can pass category variable to display exact count with tag within specific category. Here is my current code:

$tag = get_term_by(‘name’, $tags,’post_tag’);
$count = $tag->count;

reference: https://codex.wordpress.org/Function_Reference/get_term_by

Read more here:: count posts with comman tags within specific category

Leave a Reply

Your email address will not be published. Required fields are marked *