Skip to main content

How to Use Blogger Conditional Tags

Hey! Today I will show you how to use Bloggers' conditional tags. Blogger is one of the most used blogging platform. Almost all the services that it provides is free to use. And there are some unique functions that can make your blog standout. In this post we are going to discuss about conditional tags in Blogger. These are called conditional tags because you can use these tags under certain condition. With the help of these conditional you can give different looks to each pages and post in Blogger. You can also add a Widget that will appear in post page or in particular post. You can add any codes which will be wrapped in Blogger Conditional Tags.
Conditional Tags can be used anywhere in your Template. It means you can customize your template in any way you want. But these tags can't be used in section or in a widgetbox. Let's see the Blogger Conditional Tags.

How to Use Blogger Conditional Tags

You can see the structure of Blogger Conditional Tags in quotes below. It is made up of <b:if> tag which is the opening of the conditional tags. Cond attribute is used to specify the condition under which the texts or codes will be added. And a closing </b:if> tag. You must not forget to close the opening <b:if> tag with closing </b:if> tag. Have a look at the slight look at the Blogger conditional tag below.
<b:if cond='YOUR CONDITION HERE'>
</b:if>
Home Page
With the help of this conditional tags you can place a specific texts or your desired codes wrapped under this tag. The codes that you will add in this conditional tag of Blogger will only appear in HomePage and the entire pages, posts, labels etc. will be unaffected. You can see this tag below.

<b:if cond='data:blog.url == data:blog.homepageUrl'>
PLACE YOUR CODE HERE
</b:if>
You will have to place the code which you want to make appear in home page in place of PLACE YOUR CODE HERE in line 2.

Post Page or Item Page
This tag will help in adding codes or texts which will only appear in posts page. This tag can help you in adding different look to the posts or item page from the entire blog. See the Conditional Tag below.

<b:if cond='data:blog.pageType == "item"'>
PLACE YOUR CODE HERE
</b:if>
As I explained above you will have to place the codes or scripts in place of PLACE YOUR CODE HERE. And this conditional will add the codes in all the posts.

Labels Page
Now you may also want a particular Script or Code that will only appear in the Label Page.

<b:if cond='data:blog.searchLabel'>
PLACE YOUR CODE HERE
</b:if>
Now Place your Code or Script by replacing PLACE YOUR CODE HERE and save your Template. Now your particular code for labels page will appear.

Archive Page
With the help of this conditional tag of Blogger you can insert texts, contents, codes, scripts etc. in the archive page of your Blogger Blog and the remaining pages and posts will remain unaffected.

<b:if cond='data:blog.pageType == "archive"'>
PLACE YOUR CODE HERE
</b:if>
Add your desired codes in the specified place and save your template. After that your desired content will only appear in archive pages.

Specific Posts/Pages/URLs
This one will help you in adding particular codes or gadgets that will only appear in specific URL or specific post.

<b:if cond='data:blog.url == "PUT_URL_HERE"'>
PLACE YOUR CODE HERE
</b:if>
If you want to add Meta Keywords that will only appear in particular post than you can add the URL of that post in place of PUT_URL_HERE in the first line of above code. After that add your required codes or Scripts in place of PLACE YOUR CODE HERE in line 2.

Index Page
If you want to add the codes, content that will only appear in Home Page, Labels Page and Archive Page than this conditional tag of Blogger can help you. Take a look at the tag below.

<b:if cond='data:blog.pageType == "index"'>
PLACE YOUR CODE HERE
</b:if>
Add this conditional anywhere you want it to appear in  Home Page, Labels Page and Archive Page and place your code by replacing PLACE YOUR CODE HERE in line two.

Static Pages
Many of you may want to give little different look to your static page. This condition can help you in doing that. You can add gadgets, codes, scripts etc. that will only appear in static page of your Blogger blog. The tag is given below.

<b:if cond='data:blog.pageType == "static_page"'>
PLACE YOUR CODE HERE
</b:if>
Now you can add your required codes in the specified place.

Posts and Static Pages
If you wish to add particular gadget or content that will have to appear in Posts pages as well as Static Pages than use the conditional tag of Blogger given below.

<b:if cond='data:blog.url == data:post.url'>
PLACE YOUR CODE HERE
</b:if>
Now place the code you want to make appear in posts and static pages in place of PLACE YOUR CODE HERE and save your template. After saving your desired contents will start to appear on posts and static pages of your blog.

First Post
This is not a page of your blog. It is first post of your pages that contains multiple posts. Adding any codes under this condition will be only applicable for the first post of the multiple posts page. If you want to use this conditional tag than take a look at the tag below.

<b:if cond='data:post.isFirstPost'>
PLACE YOUR CODE HERE
</b:if>
Adding any code in place of PLACE YOUR CODE HERE in the second line will be only applicable on the first post of your multi-post page and the remaining content will remain unaffected.
Well these were the nine widely used Blogger Conditional Tags.
If you want to add alternate for the <b:if> statement than you will have to use <b:else/> tag. Take a look close look at the tag below to know how to use alternate content for Blogger Conditional Tags.
<b:if cond='data:blog.pageType == "index"'>
PLACE YOUR CODE HERE
<b:else/>
<b:if cond='data:blog.pageType == "item"'>
PLACE YOUR CODE HERE
</b:if>
</b:if>
By using the above tag you can add different tags to the index page and post/item page. By using this tag the codes will display in posts page and index page of your blog. Placing the code in place of red text will make your code in index page and if you will place the codes/content in place of blue text than that code which you added in place of blue text will appear in post page.

Until now you have seen how to add particular code in each page of blogger using conditional tags of Blogger. But you can also reverse the process. It can be reversed by replacing == with != Take a look at the code below to understand
<b:if cond='data:blog.pageType != "item"'>
PLACE YOUR CODE HERE
</b:if>
If you will place the code in place of PLACE YOUR CODE HERE using above conditional tag than the code which you added in place of PLACE YOUR CODE HERE using above conditional tag for Blogger will appear in every page of your blog except the item page/post page of your Blogger blog. You can clearly see that the process is reversed by replacing == with != in the conditional tag. You can replace == in every conditional tag in this post with != to reverse the process.

That's All about the use of Blogger Conditional Tags. I hope you enjoyed reading the post. If you are facing any problem in implementing these conditional tags on your Blogger blog than feel free to ask me or you can also place a comment below.

Comments

Popular posts from this blog

Need for Speed (NFS) Carbon Cheats, Codes and Unlock Parts

Need for Speed makes some great racing games like NFS Most Wanted, Rivals etc. and Need for Speed Carbon is another 10th addition to their NFS series. It's the first game to get the PEGI rating 12+. It's a very good game with it's story line. If you are looking for some adventure and a good racing than this one will be in your game list. While playing the game you will face some difficulty in completing this game. And from than onwards you may look some cheat codes that can help you in completing NFS carbon. And to make it easier for you here is the list of some working cheat codes and trainer. But you proceed to know about cheats and tricks for Need for Speed Carbon you would like to know the adventurous story of the game. So let's start. The game is set in the fictitious city of Palmont. Soon after the player leaves the Rockport City ( remember jumping of an old bridge in last scene of NFS Most Wanted) the player drives on a route to Palmont city with his BMW ca...

How to Get Unlimited Ammo and Health in IGI 2

After many days I am sharing a cool and interesting trick for game lovers. Do you enjoy playing IGI2? Of course you like this game. But many of you may be facing verious difficult situations in completing this game. It's because the missions are really tough and you can't complete whole IGI 2 without using it's cheat codes. There are many hacking tricks for IGI available in the Internet but most of them don't work. And this is the reason I am sharing these cheat codes to you. After reading this post you will be able to play this game without losing any health and ammo. We'll use a lite application to achieve the immortality and infinite number of ammo in this game. You will have to download the software from the link that I will provide you a little later in this post. Let's first know what this software will do. It will allow you to keep your health unlimited in IGI game. And if the health will not decrease then you will never die in the game IGI. You wil...

Enhancing Productivity with Virtual Desktops in Windows 11

In the fast-paced digital age, multitasking has become an essential skill for maximizing productivity. With the release of Windows 11, Microsoft introduces an enhanced Virtual Desktop feature that empowers users to organize their workspace, manage tasks efficiently, and seamlessly switch between different contexts without the clutter. In this article, we'll delve into the world of Virtual Desktops in Windows 11 and explore how this powerful tool can elevate your productivity to new heights. Task View  The Power of Virtual Desktops Virtual Desktops in Windows 11 provide users with a dynamic way to manage their open applications and tasks. Think of them as separate workspaces, each with its own set of open apps, files, and windows. This allows you to group related activities together, effectively creating a focused environment for different projects, tasks, or workflows. Getting Started with Virtual Desktops Setting up and using Virtual Desktops in Windows 11 is a breeze: 1. Creating...