Google Ads

How to selectively show and hide widgets based on the types of pages in Blogger


As the title of this post state, you can customize your Blogger template to show or hide specific widgets based on the types of Blogger pages the widgets being loaded into. Not only the types of pages, you can also show or hide the widgets based on specific url addresses of your blog page being loaded into.

Steps:

1. Go to the "Template" section of your Blogger blog dashboard.

2. Click "Edit HTML" button.

3. Check the check box for "Expand Widget Templates".

4. Look for your widget codes section by using your browser search function to search for your widget name. Lets take an example that you are trying to customize a widget that has a title name of "Recent Posts". You should see 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>
5. Lets say you wanted to hide this widget in your homepage only. Insert this 2 lines of codes (red colored fonts) like this:
<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:if>
<b:include name='quickedit'/>
</b:includable>
</b:widget>
By using what was shown above, you can show and hide your widgets in a variety of ways:

Show widget only on Index pages (Home + Label + Update + Search)

<b:if cond='data:blog.pageType == "index"'>
Your Widget Code
</b:if>

Hide widget only on Index pages (Home + Label + Update + Search)

<b:if cond='data:blog.pageType != "index"'>
Your Widget Code
</b:if>

Show widget only on home page

<b:if cond='data:blog.url == data:blog.homepageUrl'>
Your Widget Code
</b:if>

Hide widget only on home page

<b:if cond='data:blog.url != data:blog.homepageUrl'>
Your Widget Code
</b:if>

Show widget only on post pages

<b:if cond='data:blog.pageType == "item"'>
Your Widget Code
</b:if>

Hide widget only on post pages

<b:if cond='data:blog.pageType != "item"'>
Your Widget Code
</b:if>

Show widget only on static pages

<b:if cond='data:blog.pageType == "static_page"'>
Your Widget Code
</b:if>

Hide widget only on static pages

<b:if cond='data:blog.pageType != "static_page"'>
Your Widget Code
</b:if>

Show widget only on error pages

<b:if cond='data:blog.pageType == "error_page"'>
Your Widget Code
</b:if>

Hide widget only on error pages

<b:if cond='data:blog.pageType != "error_page"'>
Your Widget Code
</b:if>

Show widget only based on URL

<b:if cond='data:blog.url == "Page URL"'>
Your Widget Code
</b:if>

Hide widget only based on URL

<b:if cond='data:blog.url != "Page URL"'>
Your Widget Code
</b:if>

Show widget only on archive pages

<b:if cond='data:blog.pageType != "archive"'>
Your Widget Code
</b:if>

Hide widget only on archive pages

<b:if cond='data:blog.pageType != "archive"'>
Your Widget Code
</b:if>
6. After you have edited your Blogger template, save it and you will see the effect immediately. 

Popular posts from this blog

A Better SKMEI 1358 Instructions Manual

A Better SKMEI 1418 / 1427 Instructions Manual

How to force stop or cancel Android download manager downloading process

SKMEI 1358 Review