How To Use Blogger Conditional Tags To Show Or Hide Widgets In Specific Pages

0
How To Use Blogger Conditional Tags To Show Or Hide Widgets In Specific Pages - In this tutorial, I will show you how to use Blogger Conditional Tags to show or hide any widget in specific pages like homepage, post pages, archive pages, etc in blogger blogspot.

conditional tags, blogger conditional tags, meta tags, blogspot tags, widget

Conditional Tags in Blogger template that allow you to specify parts of your template to be appear only under certain conditions. One particularly useful application of conditional tags is in specifying on which page or pages a HTML element should appear.

Ever wish you could display only relevant widgets onto a page, hide sidebars on certain pages, display different buttons on different pages, or apply a Meta Tags only to selected pages? Well, if applied properly, conditional tags can make all that happen.

Conditional tags in Blogger are used to tell browers what to do in certain conditionals. For example,
<b:if cond='data:blog.pageType == &quot;item&quot;'>
Hello
<b:else/>
Goodbye
</b:if>

It gives the browser the condition that when it's an item (post) page then show "Hello" otherwise, for every other pages show "Goodbye". Interesting isn't it.

A conditional tag comes handy when you are designing your Blogger blogs and customizing it from the scratch to take it to the next level. But first you need to know many types of pages are there in Blogger and then how to use the blogger conditional tags respective to that type of page. In this tutorial I will try to cover most of it, so let's start.

Conditional Tag Syntax

<b:if cond='PUT_CONDITION_HERE'>
</b:if>
If is made up of a <b:if> tag, with a cond attribute added. Condition is entered as the value of the cond attribute. Each (Opening) <b:if> tag need to be closed with a Closing </b:if> tag.

Type of Pages in Blogger and Conditional Tag for it

Item Page = Item Page refers to the individual post pages. It's the page when you Click the Title of the post or the read more link in blogger to read the full post. The Conditional tag:
<b:if cond='data:blog.pageType == &quot;item&quot;'>
Blogger 4 Ever
</b:if>

Home Page Only = It's for the homepage only.
<b:if cond='data:blog.url == data:blog.homepageUrl'>
Blogger 4 Ever
</b:if>

Index Page = It refers to every other page except item (post) pages, The Conditional Tag:
<b:if cond='data:blog.pageType == &quot;index&quot;'>
Blogger 4 Ever
</b:if>

Static Page = For static pages in blogger it will be:
<b:if cond='data:blog.pageType == &quot;static_page&quot;'>
Blogger 4 Ever
</b:if>

Archive Page = It's your archive pages in blogger. The Tag will be:
<b:if cond='data:blog.pageType == &quot;archive&quot;'>
Blogger 4 Ever
</b:if>

For a Particular Page = If you want to do something on a particular page then the Conditional Tag for it will be:
<b:if cond='data:blog.url == &quot;URL of the page&quot;'>
Blogger 4 Ever
</b:if>

The only thing that you have to do is replace "URL of the page" with your page's URL which you want to have.

Alternative Condition

Now suppose you want a conditional tag that alternates every rule. Say, in example 1, I showed how to display something only in post pages but just an " ! " mark can alternate the condition. For example, when we apply:
<b:if cond='data:blog.pageType != &quot;item&quot;'>
Hello
</b:if>

It will set the condition that to show it on every page other than post page. "Hello" is an example. but if it's implemented correctly, you can add conditions to Particular Widgets or Gadgets To Show Them In Specific Pages.

You might also like: How To Show/Hide Widgets On Specific Pages In Blogger
How To Submit Blog To Google Yahoo Bing Search Engines
How To Create Google Custom Search Engine
Tags

Post a Comment

0 Comments
Post a Comment (0)
To Top