Back to Blog

Show content in specific category in Magento

Published on 13 March 2014

Here’s a little snippet which allows you to enter specific content based on store category. This is handy if you want to show something on a page which belongs to just a specific category only.

<?php if (Mage::registry('current_category') && Mage::registry('current_category')->getId() == 18) { ?>
PUT CONTENT IN HERE FOR CATEGORY WITH ID 18
<?php } ?>

Likewise you can show either content A if on category and if not, show content on all other categories:

<?php if (Mage::registry('current_category') && Mage::registry('current_category')->getId() == 18) { ?>
PUT CONTENT IN HERE FOR CATEGORY WITH ID 18
<?php } else { ?>
PUT CONTENT FOR EVERY OTHER CATEGORY OR PAGE HERE
<?php } ?>
Let's Work Together

Got a project like this in mind?

I build bespoke AI agents, RAG systems, and high-performance WordPress & Next.js sites. Let's talk about what's possible.

Show content in specific category in Magento - Phil Owen