Sunday, May 23, 2010

To Show Widgets Only in Home Page or in Specific Page

When you add a widget to your blog, by default the widget would appear on all pages like homepage, index, archive, post and static pages.But most of the Bloggers want to know how to show widgets only in the Home Page or in Specific Pages only, the coding is so simple.



Follow these steps:

Create any widget, and place it where-ever you want, and save the template. Check if it is working (displayed) in all the pages. Remember to give a TITLE to it, like Label,BlogRoll,Adsense, Or Unique word.

And then Go to Layout > Edit HTML > Click on the Expand Widget Template Box
Then find for that Title or Unique word (by CTRL+F).

It will be something like this:

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:includable>
</b:widget>


Now Modify This as follows

To Show Widgets only in Home Page

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>


To Show Widgets only in Post Pages

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>


To Show Widget only in Archive Page

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "archive"'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>


To Show Widget only in Particular Page

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == "Particular Page URL"'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>


Replace Particular Page URL with your post URL Address.
For Example : http://yourblog.blogspot.com/2010/o5/show-widget-on-specific-pages.html


To Show Widgets in Pages other than Particular Page

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url != "Particular Page URL"'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>


To Show Widget only in Static Pages

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.pageType == "static_page"'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>


To Show Widgets only in Label Page

<b:widget id='HTML1' locked='false' title='WIDGET TITLE or UNIQUE WORD' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == "Particular_Label_Name_URL"'>
<b:if cond='data:title'>
<h2><data:title/></h2>
</b:if>
<div class='widget-content'>
...
...
...
WIDGET CODE
...
...
...
<div>
<b:include name='quickedit'/>
</b:if>
</b:includable>
</b:widget>

Replace Particular Label Name URL with your Label URL Address.
For Example : http://your_blog.blogspot.com/search/label/Label_Name

2 comments:

New Free Blogger Template said...

Nice post bro. Maybe with the demo blog about this post, more usefull.

This post is similar with my post about Type and function codes to set display widget blog

Bloggertheme said...

@New Free Blogger Template,

Thank you for your suggestion

Post a Comment