i want modification in this code to hide parent name which does not have child category.
I have tried but didn't got anything related to this.
<?php
$parent_categories = get_categories($parent_args);
foreach($parent_categories as $parent_category){ ?>
<?php //create main headings for other categories other than Uncategorized.
if($parent_category->name!="Uncategorized"){
$category_label = "By ";
echo '<br>';
echo '<h5>'.$category_label.''.$parent_category->name.'</h5>';
//fetch the parent category's id
$firstchild_args['parent'] = $parent_category->term_id;
$firstchild_categories = get_categories($firstchild_args);
//fetch all the first level children categories
//fetch all the first level children categories
$limit=15; // Set Child limit here
$counter=0;
foreach($firstchild_categories as $firstchild_category){
if($counter<$limit){
$output = "";
$output = $output."<div class=\"checkboxes-group\">";
$output = $output." <input type=\"checkbox\" value=".$firstchild_category->slug." class=\"js-filter-checkbox\" name=\"category[]\" id=".$firstchild_category->cat_ID.">
<span style='font-size: 17px; color: #404040;'>".$firstchild_category->name;
$output = $output."</div>";
echo $output;
$output = $output."</form>";
$counter++;
}
}
}
} ?>