Below code Put in your phtml file. @parentCategoryId
pass category id.
<?php
$categoryChild = Mage::helper('your_helper')->getCustomMenuCategory($parentCategoryId);
if (count($categoryChild) > 0) {
?>
<div class="child-category">
<ul class="child-subcategories">
<?php foreach ($categoryChild as $child): ?>
<li>
<a href="<?php echo $child->getUrl() ?>">
<span><?php echo $child->getName() ?></span></a>
</li>
<?php endforeach; ?>
</ul>
</div>
and below in your helper
public function getCustomMenuCategory($categoryId) {
try {
$categoryChild = Mage::getModel('catalog/category')->load($categoryId)->getChildrenCategories();
if (count($categoryChild) > 0) {
return $categoryChild;
} else {
$parentcategories = Mage::getModel('catalog/category')->load($categoryId)->getParentCategory()->getChildrenCategories();
return $parentcategories;
}
}
} catch (Exception $ex) {
Mage::log($ex, null, 'subcategory.log');
}
}
Hope this will work.
If this will work for you then accept it.