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

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

Remove "Restore Previous Versions" Option from Context Menu in Windows

Windows has a feature which lets you to restore the previous versions of any drive, folders, or files. Actually, it is a part of " File History " service of Windows which helps in recovering accidentally deleted files by copying them to a backup location. If you don't need this service, then you can can disable this by turning off the File History service in Services Manager. Open Run dialog box by pressing Windows and R key simultaneously. Type services.msc and press OK. It'll open Services Manager. In Services Manager, right click on the " File History Service " and choose Properties . Now, change the startup type to Disabled and then click on the Apply button. Done! After disabling this service, you'll notice that the " Restore Previous Versions " item is still available in the Context Menu. Follow the following steps if you want to get rid of the " Restore Previous Versions " from the Context Menu in your Win

Top 5 Alternatives to Extratorrent

In an unforeseen move, Extratorrent decided to shut down few months ago. It was one of the most popular torrent site, but now users who visit it's homepage are greeted with a message which clearly states they are not going to return in the future. Now that they are gone, various clone sites such as extratorrent.cd has been setup to squeeze money from the confused visitors via its advertisements. People visiting these clone sites should know that the original ExtraTorrent owners have deleted all data, and none of the impostors have access to the old ExtraTorrent files. There are many alternatives out there. You just need to look at the right place. Take a look at the following original torrent sites which might entice you. 1337x.to 1337x is probably the best designed torrent site you'll ever come across. Although it lacks the ExtraTorrents' rating system, nonetheless, most of the contents are verified by moderators. The site has easy-to-navigate subsections whic