Full List and Uses Of Blogger Conditional Tag

Add Tool

Full List and Uses Of Blogger Conditional Tag


Conditional tags are Blogger template tags that allow you to specify parts of your template to appear only under certain conditions. One particularly useful application of conditional tags is in specifying on which page or pages a HTML element should appear.

Ever wish you could display only relevant widgets onto a page, hide sidebars on certain pages, display different buttons on different pages, or apply a meta tag only to selected pages? Well, if applied properly, conditional tags can make all that happen.

Conditional tag syntax

The syntax is like this:

<b:if cond='PUT_CONDITION_HERE'>
</b:if>

It is made up of a <b:if> tag, with cond attribute added. Condition is entered as the value of the cond attribute. Each (opening) <b:if> tag need to be closed with a closing </b:if> tag.

 List of conditional tags

Below is a list of conditional tags that target specific pages. I only list the opening tags here. Just make sure you include the closing </b:if> tag when applying a conditional in your template.

  1. Index (list) pages
    Index pages include homepage, labels page and yearly archive page.
    <b:if cond='data:blog.pageType == "index"'>
  2. Post (item) pages
    <b:if cond='data:blog.pageType == "item"'>
  3. Static pages
    <b:if cond='data:blog.pageType == "static_page"'>
  4. Archive pages
    <b:if cond='data:blog.pageType == "archive"'>
  5. Homepage
    <b:if cond='data:blog.url == data:blog.homepageUrl'>
  6. Specific page/URL
    <b:if cond='data:blog.url == "PUT_URL_HERE"'>
  7. Post and static pages
    <b:if cond='data:blog.url == data:post.url'>
  8. Label-search pages
    <b:if cond='data:blog.searchLabel'>
  9. First post
    This is not a page, but a conditional for the first post. Used for targeting the first post on multi-post pages.
    <b:if cond='data:post.isFirstPost'>

Applying conditional tags

  • To apply a conditional tag to a content, simply put the content between the opening <b:if cond…> and the closing </b:if>, like so:
    <b:if cond='data:blog.pageType == "item"'> 
    CONTENT (TO BE EXECUTED IF CONDITION IS TRUE)
    </b:if> 
    In the example above, the content will only appear on post pages.
  • 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:
    <b:if cond='data:blog.pageType == "item"'> 
    CONTENT 1 (TO BE EXECUTED IF CONDITION IS TRUE)
    <b:else/>
    CONTENT 2 (TO BE EXECUTED IF CONDITION IS FALSE)
    </b:if> 
    You can place the conditional anywhere in your template HTML, except inside a section or inside a widget content box. The content can be a div, a section, a style tag, another conditional tag etc.
  • Reversing a condition
    A condition can be reversed simply by replacing the comparison operator from == (is equal to) to != (is not equal to), like so:
    <b:if cond='data:blog.pageType != "item"'> 
    CONTENT (TO BE EXECUTED IF CONDITION IS TRUE)
    </b:if> 
    In the example above, the content will only appear on pages other than post pages (i.e. removed/hidden from post pages). This method is not applicable to Label-search and First Post conditionals.

Tags: Blogger Conditional tags, Specific URLs with conditional tags, Conditional Tags for Blogger, Using Conditional Tags in Blogger, List and usage of blogger conditional tags, Blogger Template Tags
Payza

About Masum Billah

Full List and Uses Of Blogger Conditional Tag 1stWebSuite website seo tool is a free website ranking tool site provides a lot of on page and off page seo useful tools for you. On this site, we have a large number of website ranking tools


SIGN UP TO GET UPDATE TO YOUR INBOX




Discuss about: Full List and Uses Of Blogger Conditional Tag


adf.ly