Display related products anywhere in Magento



By default Magento displays Related products block in the product description page. Some times we wants to display the related products on the product listing page or any other places in Maganto. It is very simple just use the below code and display the related products from the product Id.
<?php

//Start loading a product resources
$product = Mage::getModel('catalog/product')->load($productId);

//save the product into the registry
Mage::register('product', $product);

//display $product's related products
echo $this->getLayout()->createBlock('catalog/product_list_related')->setTemplate('catalog/product/list/related.phtml')->toHtml();

?>

Refresh the page and now your related products will be display. Hope this will help to someone.