Check if homepage with PHP in Magento

This snippet wraps around your homepage-specific code in order to only display when on the homepage of your store.

<?php
// IF WE ARE ON HOMEPAGE
if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'
) : ?>
// Put your homepage-only code in here.
<?php endif; ?>

The ‘home’ identifier may be different for your site so amend as necessary.

Useful post? Share it

Leave a Reply

Your email address will not be published. Required fields are marked *