Blogger conditional tags are the main function of a blogger template. You can't create a Blogger Template without this XML tags. You can say that Conditional Tags are the brain of a blogger template. You can function your site in various ways with these conditional tags (XML). But at first you have to know all the tags an uses of these tags. Here are all the Conditional Tags & you will also get that why and where to use these.
Contents
- 1 List of Conditional tags for page types
- 2 Archive page
- 3 Error Page (404)
- 4 Index Page
- 5 Homepage
- 6 Item (post) pages
- 7 Label page
- 8 Specific Label Page
- 9 Search page
- 10 Specific Search Query page
- 11 Static page
- 12 Specific Static page by URL
- 13 AND/OR/NOT
- 14 How to Use conditional tags
- 15 Example Applications
A conditional template tag in Blogger looks like This
<b:if cond='condition_expression'>
<!-- content when condition is satisfied -->
</b:if>
List of Conditional tags for page types
Here Is All The Conditional Tags You Need
Archive page
This XML is tag for Archive Page.
<b:if cond='data:blog.pageType == "archive"'>
<!--archive_Page-->
</b:if>
Error Page (404)
This XML is tag for Error Page.
<b:if cond='data:blog.pageType == "error_page"'>
<!-- all error pages-->
</b:if>
Index Page
This XML is tag for Index Page or Post page shown on Homepage.
<b:if cond='data:blog.pageType == "index"'>
<!-- all index pages -->
</b:if>
Homepage
This XML is tag for for Homepage only codes inside this won’t be shown on other pages.
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<!-- only homepage -->
</b:if>
Item (post) pages
This XML is tag for post pages will shown on post page and page posts also.
<b:if cond='data:blog.pageType == "item"'>
<!-- all item pages -->
</b:if>
Specific Post by URL
This XML tag is only for 2014/08/foo.html this post only.
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "2014/08/tittle.html"'>
<!-- a item page from august 2014 with post-title 'tittle'-->
</b:if>
Label page
This XML tag is for Label or Category page only.
<b:if cond='data:blog.searchLabel'>
<!-- all label pages -->
</b:if>
Specific Label Page
This XML tag is for XML Label only. (Change XML with your Desire label.)
<b:if cond='data:blog.searchLabel == "XML"'>
<!-- for label 'foo' -->
</b:if>
Search page
This XML is tag for Search Page. Code inside this tag will only be shown on Search Page.
<b:if cond='data:blog.searchQuery'>
<!-- all search pages -->
</b:if>
Specific Search Query page
This XML is tag for Search Page HTML. Code inside this tag will only be shown if anyone search for HTML.
<b:if cond='data:blog.searchQuery == "HTML"'>
<!-- for query 'foo' -->
</b:if>
Static page
This XML is tag for Static Pages only.
<b:if cond='data:blog.pageType == "static_page"'>
<!-- all static pages -->
</b:if>
Specific Static page by URL
This XML is tag for Specific Static pages only. Example /Contact.html change with your code.
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/Contact.html"'>
<!-- a specific static page with name 'foo' -->
</b:if>
AND/OR/NOT
and is add two conditional tag, or is for foo page or another page, not is for not on this page.AND example
<b:if cond='data:blog.pageType == "index"'>
<b:if cond='data:blog.searchQuery'>
<!--search_page AND index_page-->
</b:if>
</b:if>
OR example
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/foo.html"'>
<!-- static_site foo OR static_site bar -->
<b:else/>
<b:if cond='data:blog.url == data:blog.canonicalHomepageUrl + "p/bar.htm"'>
<!-- static_site foo OR static_site bar -->
</b:if>
</b:if>
NOT example
<b:if cond='data:blog.pageType != "item"'>
<!-- all pages except item pages -->
</b:if>
<b:if cond='data:blog.url != data:blog.homepageUrl'>
<!-- all pages but NOT homepage -->
</b:if>
How to Use conditional tags
To apply a conditional tag to some content, simply put the content inside the opening <b:if cond…> and the closing </b:if>
Example
<b:if cond='data:blog.pageType == "item"'>
# THIS CONTENT WILL BE EXECUTED IF CONDITION IS TRUE
</b:if>
In the example above, the content will only appear on post pages. The content can be a div, a section, a style tag or another conditional tag etc.
If you want to specify a alternate content (when the condition is false), you need to insert a <b:else/> tag followed by the content, like this:
Example
<b:if cond='data:blog.pageType == "item"'>
# THIS CONTENT WILL BE EXECUTED IF CONDITION IS TRUE
# i.e. if current page is post (item) page
<b:else/>
# THIS CONTENT WILL BE EXECUTED IF CONDITION IS FALSE
# i.e. if not post page
</b:if>
The <b:else/> also works like an OR operator as explained above.
Hope you understood the blogger conditional tags or XML tags and what and why these tags use for. But still if your having trouble don’t be shy to comment below. Share this post help us spread.
Special thanks to https://ultimatebloggerguide.blogspot.com

Don'tForget The comment section
ReplyDelete