, ,

Most wanted hack – widgets only on your selected page

Unlike wordpress, to display your widgets only in the home page, and not in the post / archieve page or vice versa have always been challenging in blogger as all sidebar bar widgets are linked to all pages in blogger including home page . But be relaxed here I am going to post a  hacking code, so that you can select the option which sidebar widget you want to show in blogger homepage and which one in all other blogger post pages.

Add the widget in blogger layout where you want to display in blogger.Now you want to select on which pages of blogger it should be displayed.

1.First step:
Go to “Edit HTML” page.
Mark “Expand Widget Templates”

2 Second step:
Find the code

HTML1

The number can be any like 1,2,3,4 it depends on your no of widget your are adding but the title to the widget you gave will be same. If your widget is ‘recent posts’, then the HTML code for the widget will be something like this.

<b:widget id=’HTML1′ locked=’false’ title=’Recent Posts’ type=’HTML’>
<b:includable id=’main’>
<!– only display title if it’s non-empty –>
<b:if cond=’data:title != “”‘>
<h2 class=’title’><data:title/></h2>
</b:if>
<div class=’widget-content’>
<data:content/>
</div>

<b:include name=’quickedit’/>
</b:includable>
</b:widget>

and you will find many codes like these so keep on matchng the title name of widget of them to which you want to show on different pages.

3. Third step: After finding the code of widget you want to display on different pages add the red blue to them as i have shown below.

To display the any Blogger widget only in HomePage


<b:widget id=’HTML1′ locked=’false’ title=’Recent Posts’ type=’HTML’>
<b:includable id=’main’>
<b:if cond=’data:blog.url == data:blog.homepageUrl’>
<!– only display title if it’s non-empty –>
<b:if cond=’data:title != “”‘>
<h2 class=’title’><data:title/></h2>
</b:if>
<div class=’widget-content’>
<data:content/>
</div>

<b:include name=’quickedit’/>
</b:if>
</b:includable>
</b:widget>





To display widget in all posts pages but not in HomePage

<b:widget id=’HTML1′ locked=’false’ title=’Recent Posts’ type=’HTML’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType == “item”‘>
<!– only display title if it’s non-empty –>
<b:if cond=’data:title != “”‘>
<h2 class=’title’><data:title/></h2>
</b:if>
<div class=’widget-content’>
<data:content/>
</div>

<b:include name=’quickedit’/>
</b:if>
</b:includable>
</b:widget>

To Display Widget In Static Pages

 

<b:widget id=’HTML1′ locked=’false’ title=’Recent Posts’ type=’HTML’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType == “static_page”‘>
<!– only display title if it’s non-empty –>
<b:if cond=’data:title != “”‘>
<h2 class=’title’><data:title/></h2>
</b:if>
<div class=’widget-content’>
<data:content/>
</div>

<b:include name=’quickedit’/>
</b:if>
</b:includable>
</b:widget>

 

 

To hide widgets in static pages

 

<b:widget id=’HTML1′ locked=’false’ title=’Recent Posts’ type=’HTML’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType != “static_page”‘>
<!– only display title if it’s non-empty –>
<b:if cond=’data:title != “”‘>
<h2 class=’title’><data:title/></h2>
</b:if>
<div class=’widget-content’>
<data:content/>
</div>

<b:include name=’quickedit’/>
</b:if>
</b:includable>
</b:widget>

 

 To display widget only in archive pages
<b:widget id=’HTML1′ locked=’false’ title=’Recent Posts’ type=’HTML’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType == “archive”‘>
<!– only display title if it’s non-empty –>
<b:if cond=’data:title != “”‘>
<h2 class=’title’><data:title/></h2>
</b:if>
<div class=’widget-content’>
<data:content/>
</div><b:include name=’quickedit’/>
</b:if>
</b:includable>
</b:widget>

After adding the highlighted conditional code above,  save the template and view the blog.