domdomrung

Target Your Widget or content any where with conditional tags

preview In this post I going to show you how add widget, buttons or anything else only on home page, post page, static page and only Selected post. you can do that with conditional tags. Conditional tags are Blogger template tags that allow you to specify parts of your template to appear only under certain conditions. The Conditional Tags can be used in your Template files to change what content is displayed and how that content is displayed on a particular page depending on what conditions that page matches.
 

Conditional tags syntax

 

Update on 26-5-2013

The Syntax is Like This
<b:if cond='PUT_CONDITION_HERE'> 
</b:if>


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.


 


Below is List of Conditional Tags



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.  Home Page Only


<b:if cond='data:blog.url == data:blog.homepageUrl'>


3. Post (item) Page Only



<b:if cond='data:blog.pageType == "item"'>


4. First Post



This is not a page, but a conditional for the first post.



<b:if cond='data:post.isFirstPost'>


5. Static Page



<b:if cond='data:blog.pageType == "static_page"'>


6. Archive Pages



<b:if cond='data:blog.pageType == "archive"'>


7. Specific Page/URL



<b:if cond='data:blog.url == "PUT_URL_HERE"'>


8. Post and Static Page



<b:if cond='data:blog.url == data:post.url'>


9. Label-Search Pages



<b:if cond='data:blog.searchLabel'>


You can place these conditional tags any where in your template HTML Area. If you have any Trouble post your comments below I will try to make possible..thanks for reading our post.


How to apply 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 Below code.



<b:if cond='data:blog.pageType == "item"'>
Here is Your CONTENT
</b:if>


in the example above, the content or widget show only on post pages..  I am writing a few  more examples as soon as time Allow.