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

前端 未结 1 1669
傲寒
傲寒 2021-01-25 13:29

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 pos

相关标签:
1条回答
  • 2021-01-25 14:14

    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

    0 讨论(0)
提交回复
热议问题