Filter Posts By Label On Your Blogger Main Page

To apply this method, edit your blogger sites XML template (be sure to back it up first!), and click "Expand Widget Templates". Now look for the line:
<b:loop values='data:posts' var='post'>
And find the matching </b:loop> tag.
Replace them and everything between them with the following code:
<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.isLast == &quot;true&quot;'><b:if cond='data:label.name != "Label_To_Filter"><b:include data='post' name='printPosts'/></b:if></b:if></b:loop></b:if><b:else/><b:include data='post' name='printPosts'/></b:if></b:loop>
Now look for the last </b:includable> tag you can find, and paste this code directly after it:
<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 == "item"'><b:include data='post' name='comments'/></b:if></b:includable>
Note that this code has a few bugs:
  1. Posts with no label will not be displayed on the main page.
  2. The filtered label must be the last label of a filtered post.
  3. If all your recent stories belong to the filtered category, your blog may appear empty.
Filter Posts By Label On Your Blogger Main Page
Leony Li

Copied from Zo Hornbill for trying myslef. 
Previous
Next Post »
0 Komentar