Adfly Links not working Find Direct Links HERE

Using Conditional Tags in Blog to Display Selective Widgets or Post Title

Some times Conditional Tags Proves very powerful.They can help a lot to alter our Template in our own what.For example there is java script running all pages of our blog.And we want show that script only on homepage or post page only, Then this can be easily done if we have knowledge of conditional tags.So lets start.

Before Doing Operations on your Template Please back UP it

Terms Which we are going to discuss :)
home page- I think you people know it very well
Archive Page- Refers to archive pages..
Item Page - Refers to Post Pages
Index Page - Includes home page + label page + search results page

Selective Display..

you can use the following conditions to check or display different items on the page.

If You want to display a Welcome message only on the home page ..

<b:if cond='data:blog.url == data:blog.homepageUrl'>
Welcome massage

Displaying something on all pages other than the homepage

<b:if cond='data:blog.url != data:blog.homepageUrl'>
i am everywhere except homepage

Displaying something only on the Archive Pages..

<b:if cond='data:page.type == &quot;archive&quot;'>
I am on Archive Pages

Displaying Item other than Archive Pages..

<b:if cond='data:page.type != &quot;archive&quot;'>
i Don't like Archive page

Displaying something on post page only

<b:if cond='data:page.type == &quot;item&quot;'>
I am on a post page

Displaying something on non post page only

<b:if cond='data:page.type != &quot;item&quot;'>
This is a non post page

Now displaying something on a particular url only (it can be a particular post page only or something like that)

<b:if cond='data:blog.url == &quot;Page URL on which you want to display&quot;'>
The Item to displayed(widget or something like that)

(you will have to replace Page URL on which you want to display with the url where you need the widget to be displayed..)

Now displaying something on all pages other than a particular URL

<b:if cond='data:blog.url != &quot;Page_Url on which you don't want display item or widget&quot;'>
The item here will not be displayed on The_Particular_Page_Url

Now how to use two conditions (or more).

<b:if cond='data:blog.url != &quot;The_Particular_Page_Url1&quot;'>
<b:if cond='data:blog.url != &quot;The_Particular_Page_Url2&quot;'>
this is not Particular_Page_Url1 and this is not Particular_Page_Url2

the else thing..

What if you need to display something on the homepage and something else on all other pages.. here comes the use of if else

<b:if cond='data:blog.url == data:blog.homepageUrl'>
This is the homepage
This is not the homepage
line 3

Different combination's are possible..

OR conditions can't be used
AND conditional statements can't be used

The main Disadvantage is that we can't enclose a whole widget code within the b:if tag.. otherwise we will get some message telling that a b:section can't have b:if s i.e you can wrap an unexpanded widget within a b:if condition

Wrapping a widget with the conditional tags
Every widget other than the Blog Post Widget has this general structure

<b:widget id='something' locked='' title='' type=''>
<b:includable id='main'>
somethings here

Wrapping conditional tags can be done as

<b:widget id='something' locked='' title='' type=''>
<b:includable id='main'>
<b:if cond='data:blog.url == &quot;The_Particular_Page_Url&quot;'>
some things here

this code will display the widget on The_Particular_Page_Url only (you have to provide this url)


  1. Thx for the info!
    I've updated my blog contact-page and looks perfectly now.

  2. nice tut. well explained. looking forward for more awesome tuts. =]


Feel free to leave comment if you like above widget, have any questions or just say Hi! :)