magento - category name and image in static block?

magento - category name and image in static block?

September 6, 2026 · Illustrated author avatarBy Stefan Bogdanescu
magento - category name and image in static block?

Referencing Category Name and Image from Static Blocks in Magento

Are you looking to display your category name and image directly from within a static block in Magento? This is a common requirement for many online stores. Let me guide you through the process.

Understanding Static Blocks and Categories

In Magento, static blocks are reusable chunks of content that can be inserted into various parts of your store using block references. They’re perfect for including repeated elements like banners or special offers across multiple pages.

On the other hand, categories provide a hierarchical structure to organize your products. Each category has its own name and image (which is actually a logo).

Referencing Category Name

To pull the category name into a static block, you’ll use Magento’s template language called phtml files. Here are the steps:

  1. Create a new static block through the Magento admin panel under “CMS > Static Blocks.” Set the “Identifier” to something unique like “category_name_block.”

  2. Edit your category view file (catalog_category_view.phtml) located at \app\design[your_theme]\template\catalog\category\view.phtml.

  3. Add a new line before or after the code for displaying products in this file:

<?php echo $this->getChildHtml('category_name_block') ?>

This will insert your static block at that location, which will be filled with the category name and image as described next.

Referencing Category Image

To display the category logo/logotype, you’ll need to use Magento’s built-in block type called “core/text_list.”

  1. In your “category_name_block” static block content area, add a new line:
{{block class="Magento\Cms\Block\Template" template="Magento_Catalog::product/list.phtml"}}
  1. Create a custom template at /app/design/[your_theme]/ Magento_Theme/templates/product/list.phtml.

  2. In this template file, place the following code:

<?php $category = $block->getCurrentCategory(); ?>
<img src="<?php echo $this->getBaseUrl() . 'media/wysiwyg/catalog/category/' . $category->getImage() ?>" alt="<?php echo $category->getName() ?>"/>

Make Sure Your Categories Have Images

Remember, for this to work, you must upload a category logo in the backend (“Catalog > Manage Categories”). The image will be stored under “media/wysiwyg/catalog/category/” with the same filename as your category ID.

Conclusion

With these steps, you should now be able to display both the name and image of your current category directly within any static block across your Magento store. This is a powerful technique for adding dynamic content without modifying core files or creating complex templates.

Remember to use the {{block class="Magento\Cms\Block\Template" template="Magento_Catalog::product/list.phtml"}} pattern whenever you need to include PHP logic from within static block content.

For more advanced customization techniques, consider exploring our guide on extending Magento’s core functionality without modifying it directly.

Catalog Themes Admin

Our network