• I have the following which is placed on and its printing all the child categories of the parent as it should.

    However, its showing the link even when there is no posts within that category, i need it to only show the child categories that actually have posts within them, is that possible?

    <?php 
    
    			$queried_object = get_queried_object();
    			$term_id = $queried_object->term_id;
    			$taxonomy_name ='product-category';
    			$termchildren = get_term_children( $term_id, $taxonomy_name );
    
    														foreach ( $termchildren as $child ) {
    															$count = 1;
    															$term = get_term_by( 'id', $child, $taxonomy_name );
    															$childtermid = $term->term_id;
    
    															echo '<div class="col-sm-3">
    																<article>';
    
    																echo '<h2>';
    																	echo '<a href="' . get_term_link( $child, $taxonomy_name ) . '">';
    
    																		echo '' .$term->name . '';
    
    																	echo '</a>';
    																echo '</h2>';
    
    															echo'</article>
    
    															</div><!-- /col -->';
    
    															if ( 0 == $count%4 ) { echo '</div><div class="row">';}
    
    															$count ++;
    														}
    
    			 ?>
  • The topic ‘CustomTaxonomy Cats Showing When No Posts?’ is closed to new replies.