Summary of Necessary Conditional Tags in Blogspot
Hello everyone, as you all know, the conditional tag ifplays a very important role for blogspot, today I would like to summarize all the necessary conditional tags for blogspot, blogger.
Summary of all if blogspot tags in the new version, conditional tags used in the process of designing template s, optimizing blogspot, installing add-ons. The conditional tag in the new version looks more concise and professional than the old version, so bloggers also use it more often.
Table of Contents
Here are some conditional tags for blogspot in new and old versions:
0. Conditional tag for Layout Mode
<b:if cond='data:view.isLayoutMode'> ... </b:if>
1. Home page condition tag (Home)
New: <b:if cond='data:view.isHomepage'> … </b:if>
Old: <b:if cond='data:blog.url == data:blog.homepageUrl'< … </b:if>
2. Index page condition tags(Including /search, /search/label, /search?q=, MultipleItems...)
New: <b:if cond='data:view.isMultipleItems'> … </b:if>
Old: <b:if cond='data:blog.pageType == "index"'> … </b:if>
3. Conditional tags for Posts and Pages (Page and Post
New: <b:if cond='data:view.isSingleItem'> … </b:if>
Old: <b:if cond='data:blog.pageType in ["item", "static_page"]'> … </b:if>
4. Conditional tags for posts (Post)
New: <b:if cond='data:view.isPost'> … </b:if>
Old: <b:if cond='data:blog.pageType == "item"'> … </b:if>
5. Conditional tag for static page (Page)
New: <b:if cond='data:view.isPage'> … </b:if>
Old: <b:if cond='data:blog.pageType == "static_page"'> … </b:if&gr;
6. Conditional tag for the Search Label . page
New: <b:if cond='data:view.isLabelSearch'> … </b:if>
Old: <b:if cond='data:blog.searchLabel'> … </b:if>
7. Conditional tags for Archive Pages
New: <b:if cond='data:view.isArchive'> … </b:if>
Old: <b:if cond='data:blog.pageType == "archive"'> … </b:if>
8. Conditional tag for Search Page
New: <b:if cond='data:view.isSearch'> … </b:if>
Old: <b:if cond='data:blog.searchQuery'> … </b:if>
9. Conditional tag for error page (Error 404)
New: <b:if cond='data:view.isError'> … </b:if>
Old: <b:if cond='data:blog.pageType == "error_page"'> … </b:if>
10. Conditional tag for preview page
<b:if cond='data:view.isPreview'> … </b:if>
11. Condition card for mobile
New: <b:if cond='data:blog.isMobile'>...</b:if>
Old: <b:if cond='data:blog.isMobile == "true" '>...</b:if>
12. If else conditional tag for mobile and desktop
<b:if cond='data:blog.isMobile'>
Content only visible on mobile
<b:else />
Content only visible on desktop
</b:if>
13. Apply for 1 single label
<b:if cond='data:view.isLabelSearch == "blogger"'>
The content is only displayed when searching for the blogger's name label
</b:if>
14. Apply to all posts with blogger label (put in loop)
<b:if cond='data:post.labels any (l => l.name == "blogger")'>
For the label named Blogspot
</b:if>
15. Conditional tags are not used for the search label page
<b:if cond='!data:view.isLabelSearch'> … </b:if>
16. Conditional tag not for homepage
<b:if cond='!data:view.isHomepage'> … </b:if>
or
<b:if cond='data:blog.url != data:blog.homepageUrl'> … </b:if>
17. Conditional tag for 1 single link, any self-ordered
<b:if cond='data:blog.url == "Unique Link"'> … </b:if>
18. Conditional tag for 1 of the labels
<b:if cond='data:view.search.label in ["blog", "templalte", "giodienblognet"]'>
Display content for the above labels
</b:if>
19. Conditional tags not used in labels
<b:if cond='data:view.search.label not in ["blog", "templalte", "giodienblognet"]'>
Display content for the above labels
</b:if>
20. Conditional tag combined if else for label
<b:if cond='data:view.search.label in ["template", "blog", "adsense"]'>
For the label with the name
<b:elseif cond='data:view.search.label not in ["theme", "css"]' />
For labels without a name
<b:else />
Remaining default
</b:if>
21. Another if else conditional tag for label
<b:if cond='data:blog.searchLabel == "blog"'>
Content displayed for when searching label blog
<b:elseif cond='data:blog.searchLabel == "thuat-thuat-blog"' />
Content displayed for when searching label thu-thuat-blog
<b:else />
Defaults left
</b:if>
22. Conditional tags for certain authors
<b:if cond='data:displayname == "author-name"'>
Content shown is for author 'author-name' only
</b:if>
23. Search terms tag for a certain keyword
<b:if cond='data:blog.searchQuery == "blogger"'>
Content displayed when searching for blogger keywords
</b:if>
24. Using NOT
<b:if cond='not data:view.isPage'> Not for Page </b:if>
<b:if cond='not data:view.isHomepage'> Not for home page </b:if>
<b:if cond='not data:view.isPost'> Not for posts </b:if>
Same applies to all other cards
25. Use another != (FALSE)
<b:if cond='!data:view.isPage'> Not for Page </b:if>
<b:if cond='!data:view.isHomepage'> Not for home page </b:if>
<b:if cond='!data:view.isPost'> Not for posts </b:if>
Same applies to all other cards
26. Conditional tags for new and old post links
<b:if cond='data:post.hasOlderLinks'> Old post </b:if>
<b:if cond='data:post.hasNewerLinks'> New Posts </b:if>
27. Comments
<b:if cond='data:post.numberOfComments > 0'> Number of Comments > 0 </b:if>
<b:if cond='data:post.numberOfComments < 1'> Number of Comments < 1 </b:if>
28. If there is a comment
<b:if cond='data:this.messages.blogComment != """'>:If comments</b:if>
29. Conditions card for Adsense
<b:if cond='data:post.includeAd'>...</b:if>
30. Post date condition tag
<b:if cond='data:post.dateHeader'>...</b:if>
31. Conditional tag for first post
<b:if cond='data:post.isFirstPost'>....</b:if>
And there are many other conditional tags in the template.
Some operators to use with blogspot's conditional tag
== equals, TRUE
> greater than, apply to numbers
< less than, apply to numbers
!= else, FALSE
>= greater than or equal to, apply to number
<= less than or equal to, apply to number
NOT negative
>Some other cards that you may not know
Apply to all posts labeled blogspot
<b:if cond='data:posts all (p => p.labels any (l => l.name == "blogspot"))'>
</b:if>
Does not apply to posts labeled blogspot
<b:if cond='data:posts none (p => p.labels any (l => l.name == "blogspot"))'>
</b:if>
If the blog title contains the word assignment, same goes for the page, for the post.
<b:if cond='data:blog.title contains "delivered"'> </b:if>
Conditions for post count greater than 5 posts
<b:if cond='data:posts.size gt 5'> </b:if>
Condition for post count less than 5
<b:if cond='data:posts.size lt 5'> </b:if>
Condition for post count is equal to 5
<b:if cond='data:posts.size eq 5'> </b:if>
Conditions apply to all posts with the label
<b:if cond='data:posts all (p => p.labels.any)'> </b:if>
Condition when searching for one of the keywords inside it
&l;b:if cond='data:view.search.query in ["blogspot", "blogger", "blog"]'> </b:if>
Applies to page /search not search/label
<b:if cond='data:view.isSearch and not data:view.isLabelSearch'> </b:if>
When viewing post or page details
Apply to page with id = 123456789
<b:if cond='data:view.postId == 123456789'> </b:if>
Apply to multiple posts with id
<b:if cond='data:view.pageId == 123456789'> </b:if>
Apply to multiple pages with id
<b:if cond='data:view.pageId in [11111,22222,33333]'> </b:if>
Apply to FEATUREPOST / POPULARPOSTS / BLOG is MultipleItems widget
Applies to widgets with post id 123456
<b:if cond='data:post.id == 123456'> </b:if>
Apply to the widget with the post id below
<b:if cond='data:post.id in [11111,22222,33333]'> </b:if>
Does not apply to posts with id below
<b:if cond='[111111] not contains data:post.id'> </b:if>
Archive page
Applies to archives whose year is 2020
<b:if cond='data:view.search.archive.year == 2020'> </b:if>
Applies to archives with a month of 06
<b:if cond='data:view.search.archive.month == 06'> </b:if>