I'm having issues with my coding, I'm trying to show my category's sub-categories thumbnails on the category page in all categoies.

The problem is that it's showing the same sub-category on different categories instead of just showing it into only its parent category.

CMS Block:

{{block type="core/template" template="subcategories.phtml" }}

.PHTML File:

<div class="clearfix title-container product-slider-container"></div>
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
        ->addAttributeToSelect(array('name', 'thumbnail'))
        ->addAttributeToFilter('is_active', 1)
<?php foreach ($categories as $category): ?>
<a href="<?php echo $category->getUrl() ?>"><img src="<?php echo Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . $category->getThumbnail() ?>"/></a>
<?php endforeach; ?>

This his my website where I have it set up, navigate to one of the categories in the Header menu.

2 Answers 2


Magento caches your current category. You have to options.

Remove static block and call it through xml layout update in the category. Inside the block call

<reference name="needed block"> <action method="setCacheLifetime"></action> </reference>


Get current category via



In backend go to manage categories Remove static block. Go to layout update and put

<reference name="content">
<block type="core/template" name="my_block" template="subcategories.phtml" before="-">
    <action method="setCacheLifetime"></action>

Also you may want to rename the variable $category in .phtml when you are inside the loop. You don't want any time your theme calls $category from that line of code and after to be a child category.

  • How do I set the that up?
    – cubaton3
    Oct 22, 2016 at 23:28
  • Can anyone help me set this up?
    – cubaton3
    Oct 24, 2016 at 2:20
  • I need help, can anyone help
    – cubaton3
    Oct 25, 2016 at 15:40
  • Did you try the reference method?
    – pontikos
    Oct 25, 2016 at 16:11
  • I didn't see your edit, it works like charm, just what I was looking for. But I have an issue, how can I hide the Category title showing below the thumbnails, as well as the breadcrumbs, I have the breadcrumbs disabled on the settings, but still show up. I attached an IMGUR i.imgur.com/am0PKD3.png
    – cubaton3
    Oct 25, 2016 at 18:16

Add below given code into your cms blocks design section

<reference name="content">
         <block type="core/template" name="my_block" template="subcategories.phtml" before="-">
             <action method="setCacheLifetime"></action>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.