How to get the page Title – Magento

Here's a short snippet that retrieves the page title in Magento.

You can use in your theme files or in any module.

$headBlock = $this->getLayout()->getBlock('head');

// Just to make sure it doesn't return an error

if ($headBlock) {
   echo $headBlock->getTitle();

}Code language: PHP (php)


  1. Magento Deal of the Day says:

    Is that the title code works with Custom redirects too?

    1. Rick says:

      Dunno, give it a try and let us know ๐Ÿ˜‰

Leave a Reply

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