Excluding specific popular posts in Blogger

Popular posts gadget is great. But sometimes it might display entries, that you don't want to advertise (anymore). For example, some post made for testing may be popular, but there is no need to show that to users. Or you might have an old and a new version of some article in the popular posts, and you don't wish to display the old one.



When editing your blog template, you should know you way around to not to break your blog.



To exclude posts, first write down the urls of the posts you want to exclude from popular posts. Then edit template html, expand widget templates, and find:


<b:includable id='main'>
<b:if cond='data:title'><h2><data:title/></h2></b:if>
<div class='widget-content popular-posts'>
<ul>
<b:loop values='data:posts' var='post'>

Just after those lines add one line per post to be excluded, a line like this:


<b:if cond='data:post.href != &quot;https://anotherbloggertips.blogspot.com/2011/09/dummy-post-8th-post.html&quot;'>

Then find (in the same popular posts code block):


      </li>
</b:loop>

Between those two lines, put one:


</b:if>

for each excluded posts, so if you exclude 3 posts, put 3 </b:if>s, like this:


</li>
</b:if>
</b:if>
</b:if>
</b:loop>



I have omitted the indentation of the added lines in purpose, so they "stand out" better and can easily be spotted and edited.



Excluding the post that user is currently viewing



Find:


<b:includable id='main'>
<b:if cond='data:title'><h2><data:title/></h2></b:if>
<div class='widget-content popular-posts'>
<ul>
<b:loop values='data:posts' var='post'>

After that add:


<b:if cond='data:post.href != data:blog.url'>

And add one </b:if> after the </li> line, like in the previous chapter.



You may want to shuffle the popular posts, too. Or maybe shuffle and limit the post count to certain number (like a random set of five posts from the ten most popular minus currently viewed post) – maybe more about that later.