abhi ads

Hide/Show Widgets/Gadgets in Home/post/static/archive pages in Blogger

TRENDMAG - CLEAN & RESPONSIVE BLOGGER TEMPLATE
We often want to customize our blog template/widgets with different looks. Here is one more tip ...

thumb image 2
In many Blogger templates there is a "subscribe to: Posts (Atom)" link, so that the blogger...





As some of you may have noticed, all the widgets/gadgets you add to your blog, will be displayed on all the pages by default, including the homepage as well. And I'm sure very few know that AdSense could disable your account in case you've put ad units inside the content of your contact or privacy policy pages. Therefore, hiding certain elements inside your blog pages is not only a matter of design, but it is also a requirement.

To hide (or show) widgets in particular posts, static pages, homepage or archive pages, you can use conditional tags.

Step 1. Go to Blogger's Dashboard Layout and name the HTML/Javascript gadgets that you have already added. Doing this, it will be easier for you to identify the widgets that you have in your Blogger's template. Give it a unique title so that it does not match with any of the titles of any other widgets

Step 2. Next thing to do is to go to Template and click on   Edit HTML

blogger template, edit html


Step 3. Click anywhere inside the code area and press CTRL + F  keys to open the search box

blogger template, how to


Step 4Find the HTML of your widget by typing the widget's name in the search box - hit Enter. Let's say that the title for one of my widgets is “Recent Comments". After searching for the widget's name, I will find a similar code in my template:

<b:widget id='HTML1' locked='false' title='Recent Comments' 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>

It’s the widget/gadget that you have added from Page Elements tab. All is left is to add conditional tags just below and above to hide the widget form specific pages or posts in Blogger. Let us see some examples:

<b:widget id='HTML1' locked='false' title='Recent Comments' 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 Show Blogger Widget in Post Pages only

<b:widget id='HTML1' locked='false' title='Recent Comments' 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 show the widget in any particular page

<b:widget id='HTML1' locked='false' title='Recent Comments' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == "URL of the 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 a widget only in a particular page

<b:widget id='HTML1' locked='false' title='Recent Comments' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url != "URL of the 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 show widgets only in Archive Pages

<b:widget id='HTML1' locked='false' title='Recent Comments' 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>

To show widgets only in Static Pages

<b:widget id='HTML1' locked='false' title='Recent Comments' 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 Comments' 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>

After you have added the conditional tags, Save Template and view your blog.

Abhi

Funpram is all about health, lifestyle, latest fashion & trends, entertainment, various sports and information on Education. Keep coming back for more updates & don't forget to subscribe yourself for such more good articles on various topics.

No comments:

Post a Comment

We value and welcome your opinion & suggestion.
Thanks & Regards