You must be having widgets or gadgets on your blog either in sidebar or in gadgets but there are some situations in which you want to hide or show your widgets on certain pages like About page, Privacy policy, contact us It can be for any reason like for example you want to show or hide adsense on homepage,about page, post pages, archives pages,static pages etc on your blog This hack becomes more necessary if you want to show hide adsense ads
<b:widget id='HTML4' locked='false' title='' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == data:blog.homepageUrl'><!-- custom -->
<!-- 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><!-- custom -->
</b:includable>
</b:widget>
Note- Don't forget to add </b:if>< every time you use conditional tag <b:if> at end to close the respective code otherwise you will get error message while saving the templete
<b:widget id='HTML4' locked='false' title='' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url ! == data:blog.homepageUrl'><!-- custom -->
<!-- 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><!-- custom -->
</b:includable>
</b:widget>
Why I am writing this post is because recently I wanted to put adsense on my homepage above post listing now you can tell me that its easy to just place widget in your layout and done But in my case I was having 3 adsense units on single post pages if I go ahead and add one widget on home page then problem was it will show up on every page including my post pages which are already having 3 adsense units and if I will display more than 3 adsense ads units on home page then google will definitely bann my adsense account so I wanted to show this widget on specific pages only here is how i fixed this problem using show hide widgets hack on blogger
How To Show Hide Widgets Gadgets On Specific Pages In Blogger
1) Login to Blogger and go to layout tab
2) Now add click on add a gadget and give it a unique name show that you can identify that widget in your blogger code and drag the widget to desired place
3) Now that you have added a widget to blogger blog next step is to hide show it on specific pages depending on your wish
4) Go to templates tab and click on Edit Html and expand all the small arrows in your code to expand your blog codes Note- Before clicking on edit html make sure to backup your blog template if in case anything goes wrong You can do so by clicking Restore/backupbutton on top right hand side
5) Now press CTRL+F to find the name of your widget which is the title which you gave to your widget lets say for example in my case it is "Adsense Custom widget"
6) You are going to put conditional tag which is highlighted in code as shown below to show hide widget/gadget on certain pages Below are some examples on how to hide show widgets gadgets
7) How to Show widgets only in homepage Blogger:
<b:widget id='HTML4' locked='false' title='' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == data:blog.homepageUrl'><!-- custom -->
<!-- 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><!-- custom -->
</b:includable>
</b:widget>
Note- Don't forget to add </b:if>< every time you use conditional tag <b:if> at end to close the respective code otherwise you will get error message while saving the templete
8) How to Hide widgets only in homepage:
<b:widget id='HTML4' locked='false' title='' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url ! == data:blog.homepageUrl'><!-- custom -->
<!-- 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><!-- custom -->
</b:includable>
</b:widget>
9) How to Show widgets on post pages:
<b:widget id='HTML4' locked='false' title='' 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><!-- custom -->
</b:includable>
</b:widget>
<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><!-- custom -->
</b:includable>
</b:widget>
10) How to Show widgets in specific pages:
<b:widget id='HTML4' locked='false' title='' 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><!-- custom -->
</b:includable>
</b:widget>
<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><!-- custom -->
</b:includable>
</b:widget>
Note- Replace the URL of the page with the url of your page on which you want to show widgets
11) How To hide a widget only in a particular page:
<b:widget id='HTML4' locked='false' title='' 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><!-- custom -->
</b:includable>
</b:widget>
<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><!-- custom -->
</b:includable>
</b:widget>
11) How To show widgets only in static pages:
<b:widget id='HTML4' locked='false' title='' 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><!-- custom -->
</b:includable>
</b:widget>
<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><!-- custom -->
</b:includable>
</b:widget>
12) How To Hide widgets only in static pages:
<b:widget id='HTML4' locked='false' title='' 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><!-- custom -->
</b:includable>
</b:widget>
<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><!-- custom -->
</b:includable>
</b:widget>
13) How To show widgets only in Archive Pages:
<b:widget id='HTML4' locked='false' title='' 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><!-- custom -->
</b:includable>
</b:widget>
<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><!-- custom -->
</b:includable>
</b:widget>
14) How To Hide widgets only in Google Custom Search results page:
<b:widget id='HTML4' locked='false' title='' type='HTML'>
<b:includable id='main'>
<b:if cond='data:blog.url == "URL of the Google Custom Search page results "'>
<!-- 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><!-- custom -->
</b:includable>
</b:widget>
<b:includable id='main'>
<b:if cond='data:blog.url == "URL of the Google Custom Search page results "'>
<!-- 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><!-- custom -->
</b:includable>
</b:widget>
Note- Replace the URL of Google Custom Search page results with the url of your Google custom search resultspage on which you want to show widgets
So guys this how you can show hide certain widgets/gadgets on specific pages and if you want ask me anything regarding this you can freely ask me in comment section remember that it is wise to hide show widgets on specific pages specially if you are displaying adsense ads in it For more info and guidelines visit google adsense policies TOS because there are some changes in Google TOS So go through it

No comments:
Post a Comment