简体   繁体   中英

Show posts by specific term on Blogger

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>

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM