Show posts by specific term on Blogger

1.1k Views Asked by At

I have this code that displays blog posts by tag.

It would be possible to change the section containing the loop

<b:loop values='data:post.labels' var='label'>

by any of these variables

data: blog.searchUrl
date: blog.bloggerUrl
data: blog.searchLabel
data: blog.searchQuery
data: view.url
data: view.isSearch
data: view.isLabelSearch

Or one that can do a search for a specific term.

My goal is to show on the blog home page articles that have a certain term.

<b:includable id='main' var='top'>
    <b:loop values='data:posts' var='post'>
    <b:if cond='data:blog.url == data:blog.homepageUrl'>
    <b:if cond='data:post.labels'>
    <b:loop values='data:post.labels' var='label'>
    <b:if cond='data:label.name == "NOTÍCIAS"'>
    <b:include data='post' name='printPosts'/>
    </b:if>
    </b:loop>
    </b:if>
    <b:else/>
    <b:include data='post' name='printPosts'/>
    </b:if>
    </b:loop>
</b:includable>

<b:includable id='printPosts' var='post'>
    <b:if cond='data:post.dateHeader'>
    <h2 class='date-header'>
    <data:post.dateHeader/>
    </h2>
    </b:if>
    <b:include data='post' name='post'/>
    <b:if cond='data:blog.pageType == &quot;static_page&quot;'>
    <b:include data='post' name='comments'/>
    </b:if>
    <b:if cond='data:blog.pageType == "item"'>
    <b:include data='post' name='comments'/>
    </b:if>
</b:includable>

1

There are 1 best solutions below

1
On

Unfortunately you can't do that using blogger codes only, because b:loop operator don't loop through all the posts in your blog, but only the ones in the home page which are limited.

So you have to use javascript with blogger api in order to show posts by tag.