How to hide all post's having certain labels on home page in Google Blogger?

女生的网名这么多〃 提交于 2019-12-02 08:54:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!