03 July 2010

Show / Hide any widget on Home page or any specific post pages of blogger.

Advertisements

When you add any widget to your blogger blog it displayed in Homepage and all Post pages. But now you can display or hide any widget on Home page or any specific post pages of blogger. Most of the blog authors want to show Featured Content Slider widget on Homepage only and not other post pages.

Live Demo ("Recent Posts" widget is not shown on Home page but present on post page)

Lets do this.

When you are adding a widget, give it a unique title such as Recent Posts, Featured posts, calender. Give title to already added widget.

Navigate to Dashboard >> Design >> Edit HTML >> Expand Widget Templates.
Find <b:widget id=
You will get following code:

<b:widget id='HTML1' locked='false' title='Unique Title of Widget' type='HTML'>
<b:includable id='main'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<h2 class='title'><data:title/></h2>
</b:if>
<div class='widget-content'>
<data:content/>
</div>

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

Manipulate above code as per following codes.

Display Widget  in All Blog Posts but not in Home Page

<b:widget id='HTML1' locked='false' title='Unique Title of Widget' 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 != &quot;&quot;'>
<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>

Display a widget only on Home Page and NOT on post pages

<b:widget id='HTML1' locked='false' title='Unique Title of Widget' 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 != &quot;&quot;'>
<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>

Display a Widget on Any Typical page

<b:widget id='HTML1' locked='false' title='Unique Title of Widget' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == "Typical Page URL"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<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>

Hide a widget on Specific Post

<b:widget id='HTML1' locked='false' title='Unique Title of Widget' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url != "Specific Post URL"'>
<!-- only display title if it's non-empty -->
<b:if cond='data:title != &quot;&quot;'>
<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>

All the Best!!

Related Posts

7 comments

July 5, 2010 at 2:57 AM

Great ,
It help alot
Thanks
http://www.bundelkhanddarshan.com/index.php?option=com_content&view=article&id=53&Itemid=63

AWESOM
November 21, 2010 at 2:03 AM

This is the one of the no. 1 tip for Blogger!

January 2, 2011 at 9:47 PM

Thank you! I was looking for this trick. It is really unnecessary for some blogs to show ads on home page. Because, there are many blogs who get search engine traffic to individual posts, many of those visitors don't even navigate to home page.

February 2, 2012 at 3:05 AM

Thank you :-) It worked perfect for me.

March 28, 2012 at 9:52 PM

thanks brow

Anonymous
June 26, 2012 at 2:42 PM

I have a problem with mine, the widget is still visible, I still see a bar in the place of the widget but I can't see the content, what can I do to take it away

June 26, 2012 at 8:30 PM

I am using this hack with 100% success on my various blogs. Make sure to put codes very carefully.

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More