问题
Let's consider, "Coding", "Technical","Diary" are some labels on blog and I do not want to display all "diary" label's posts on homepage (with my rest of the label post's) so what I want to do ? I want that XML code to hide post's with some labels from homepage ! [I search uncountable times same thing on search engines like yahoo,google,yandex,etc but I didn't got anything, [ hope blogger/xml community should help !]
check image to view label
回答1:
Search for the following emphasised (bold) code in your template (Template - Edit HTML)
.... <div class='post-outer'> <b:include data='post' name='post'/> <b:if cond='data:blog.pageType == "static_page"'> ....
Replace that line (aka <b:include data='post' name='post'/>
) with
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast == "true"'>
<b:if cond='data:label.name != "LabelYouWantToHide"'>
<b:include data='post' name='post' />
</b:if>
</b:if>
</b:loop>
<b:else/>
<b:include data='post' name='post' />
</b:if>
Replace LabelYouWantToHide
with the real label name you want hidden from the homepage. Also for the above code to work correctly, make sure the posts that you want to hide only has 1 label on them.
Another thing to remember is that every post in your blog (at least the ones on the homepage) should have a label otherwise they would not be visible on the homepage because the b:loop
statement wouldn't be executed for them
来源:https://stackoverflow.com/questions/35492162/how-to-hide-all-posts-having-certain-labels-on-home-page-in-google-blogger