I am sure that get_category() will help you to get the number of posts in particular category. The get_category()
function returns an object with various details.
stdClass Object
(
[term_id] => 106
[name] => Category Name
[slug] => category-name
[term_group] => 0
[term_taxonomy_id] => 108
[taxonomy] => category
[description] => This is the category description.
[parent] => 62
[count] => 17
[filter] => raw
[cat_ID] => 106
[category_count] => 17
[category_description] => This is the category description.
[cat_name] => Category Name
[category_nicename] => category-name
[category_parent] => 62
)
Where the category_count
property returns the number of posts assigned to the category. In your case, pass the category_id to the get_category()
function something like the below code:
$category = get_category( 106 );
$count = $category-> category_count;
if ($count > $breakpoint) {
// do something
}