Category thumbnail image show in home page with name

Here get category thumbnail image in home page or any page with name. html is also used in this code. First get category level after use foreach loop print name, image etc. In last check if condition $count > 10 means total iamge 10. we can increase or decrease.

<div class="grid-container-spaced">
<?php
$_categories = Mage::getModel('catalog/category')->load(2)->getChildrenCategories();
$_categories->addIsActiveFilter();
$count=1;
   foreach ($_categories as $_category):
       if($_category->getName()=='Root Catalog' && $_category->getName()=='Default Category')
       {
           continue;   
       }
       $cat = Mage::getModel('catalog/category')->load($_category->getId());    ?>
           <div class="grid12-3 mobile-grid">
   <?php
           echo '<a href="'.$cat->getUrl().'" title="'.$cat->getName().'"><img alt="'.$cat->getName().'" class="category-img" src="'.Mage::getBaseUrl('media').'catalog/category/'.$cat->getThumbnail().'"></a>';
           echo '<div class="category-name"><a title="'.$cat->getName().'" href="'.$cat->getUrl().'">'.$cat->getName()."</a></div>";
           echo '</div>';
           $count++;
       if($count>10)
       {
           break;   
       }
   endforeach;
?>
   </div>

Labels: