I used following codes but didn't work for this case:
$_category_detail=Mage::registry('current_category');
echo $_category_detail->getName();
got Fatal error: Call to a member function getName() on a non-object in /app/design/frontend/base/default/template/catalog/product/view.phtml
we make some filters and use below mention code in head.phtml:
$is_product = Mage::registry('product');
if($is_product){
if(is_object(Mage::registry('current_category'))){
$category_name = Mage::registry('current_category')->getName();
}
else{ $category_name = ""; }
}
But this only works if you go from a category to a product. If you visit the product page directly nothing is being displayed