Hello i create a function to display list of subcategory on master category page. With my functions now i see also category that no have product (empty). I need hide this empty category..
My master category and list subcategory code
<h1 style="font-size: 36px; font-weight: 400; letter-spacing: 2px; font-family: 'Oswald';"><?php echo $cat->name; ?></h1>
<p><?php echo $cat->description ; ?></p>
<!--<?php if(is_array($parent_categories_ids)){ echo'<pre>',print_r($parent_categories_ids),'</pre>'; }?> -->
<div class="list">
<ul>
<?php foreach($term_children as $child) :
$term = get_term_by( 'id', $child, 'product_cat' );
?>
<?php if( $child->count <= 0 ) {
continue;
} ?>
<li><a href="<?php echo get_term_link( $child, 'product_cat' )?>"><?php echo $term->name; ?></a></li>
<?php endforeach; ?>
</ul>
</div>
Code to try hide
<?php // Skip empty terms
if( $child->count <= 0 ) {
continue;
} ?>
But not work...