In this Post , i will share with you all blogger conditional tags and how to use them in your template, because As a blogger template developer or customizer, you must need to know about blogger conditional tags.By using conditional tags, you can specify part of your template to show in specific place, So let's Start Our tutorials...


First, The global form of conditions in blogger is :


<b:if cond='Your Condition'>
 (Code To Be Executed When Condition Is True) 
</b:if>

by changing The Red Text you will be able to show or execute any action/script in many places, the second part is the type of condition that we will place it in our codes:

  • Home Page
  • Search Page
  • Static Page
  • Post/Item Page
  • Specific Author
  • Error Page
  • Archive Page
  • Labels
  • Number of Comments
  • Comments is allowed
  • Index Page
  • Specific Page/URL
  • First Post


Note : The code is placed in The Template in any place but if you place it in layout>HTML/JavaScript or in other widgets it will not be work

Home Page
<b:if cond='data:blog.url == data:blog.homepageUrl'>
(Code To Be Executed When Condition Is True)
</b:if>

Search Page
<b:if cond='data:blog.searchQuery'>
(Code To Be Executed When Condition Is True)
</b:if>

Static Page
<b:if cond='data:blog.pageType == "static_page"'>
(Code To Be Executed When Condition Is True)
</b:if>


Post/Item Page
<b:if cond='data:blog.pageType == "item"'>
(Code To Be Executed When Condition Is True)
</b:if>

Specific Author
<b:if cond='data:post.author == "Author_Name"'>
(Code To Be Executed When Condition Is True)
</b:if>
Change Author_Name with your Author Name.
Error Page
<b:if cond='data:blog.pageType == "error_page"'>
(Code To Be Executed When Condition Is True)
</b:if>

Archive Page
<b:if cond='data:blog.pageType == "archive"'>
(Code To Be Executed When Condition Is True)
</b:if>

Labels
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == "LABEL_NAME_HERE"'>
(Code To Be Executed When Condition Is True)</b:if>
</b:loop>
Change LABEL_NAME_HERE with your label name. Label name is case sensitive.
Number of Comments
<b:if cond='data:post.numComments == [Number_Here]'>
(Code To Be Executed When Condition Is True)
</b:if>
Change Number_here with your number of comments.
Comments is Allowed
<b:if cond='data:post.allowComments'>
(Code To Be Executed When Condition Is True)
</b:if>

Index Page
Index pages include homepage, label page, search page and yearly archive page.
<b:if cond='data:blog.pageType == "index"'>
(Code To Be Executed When Condition Is True)
</b:if>

Specific Page/URL
<b:if cond='data:blog.url == "URL_HERE"'>
(Code To Be Executed When Condition Is True)
</b:if>
Change URL_HERE with your URL.
First Post
<b:if cond='data:post.isFirstPost'>
(Code To Be Executed When Condition Is True)
</b:if>


  • How To Apply Multiple Conditional Tags ?


If you want add multiple condition. It means that if first condition not work then execute second condition you can simply put <b:else/> tag.
<b:if cond='Your condition'>
Code to be EXECUTE IF TRUE
<b:else/>
Code to be EXECUTE IF FALSE
</b:if>


  • How To Apply Reverse Conditional Tags ?

If you want to reverse a conditional tag, you can do that by changing comparison operator from == (is equal to) to != (is not equal to).It means that the content will appear all of pages except post page. Remember that you can not apply this method to Label-Search and First Post conditionals.

<b:if cond='data:blog.pageType != "item"'>
(CODE TO BE EXECUTED IF CONDITION IS TRUE)
</b:if>

That's it. of you have any problem you can put it in comments *_*.