I have created Widget and want to call it from header.phtml
enter image description here
In this widget i have called Static block but widget not called.This widget have id 2
i have set code below please help me to correct this or give me another for id = "2" 
$widget = Mage::getModel('cms/widget_block')->load('2');
 $widgetBlock = $this
 ->getLayout()
 ->createBlock($widget->getType(),
 $widget->getTitle(),
 $widget->getWidgetParameters());
echo $widgetBlock->toHtml();
And
<?php
$filter = new Mage_Widget_Model_Template_Filter();
$_widget = $filter->filter('{{widget type="cms/widget_page_link" template="cms/widget/link/link_block.phtml" page_id="2"}}');
echo $_widget;
?>
 1 Answer 1
You can directly call a widget on header from admin panel create widget page.
Just click on Add Layout Update button and select page you want to display on from Display On dropdown,(here if you want to display on all page then select All Pages), then from Block Reference select Page Header (Or Page header with position) and then from Widget Options select your static block. Save the widget and check on frontend after clean cache.
- 
 it's not display where i wantKetan Borada– Ketan Borada2016年12月29日 12:10:08 +00:00Commented Dec 29, 2016 at 12:10
 - 
 did you tried other option of header like
Page Header, Primary, Central ColumnandPage Header, Primary, Left Columnetc?Piyush– Piyush2016年12月29日 12:14:17 +00:00Commented Dec 29, 2016 at 12:14 - 
 yes but i want php code to displayKetan Borada– Ketan Borada2016年12月29日 12:16:55 +00:00Commented Dec 29, 2016 at 12:16
 - 
 
 - 
 i mean i cant call exactly where i want by this method i want php codeKetan Borada– Ketan Borada2016年12月29日 12:22:34 +00:00Commented Dec 29, 2016 at 12:22
 
Explore related questions
See similar questions with these tags.