Skip to main content

Related posts. Looping with Multiple Labels

Enhancing the Related Posts code, we will now move on with Loops on multiple labels. It's advised to read Related posts with multiple conditions and then continue to read this post to understand things better.

<!--See related posts appear only if required-->
<b:if cond='data:post.labels any (label => label.name in [&quot;Blogger Customizations&quot;,&quot;Blogger Tricks&quot;])'>
<b>See related posts:</b>
</b:if>

<!--Un-ordered list tag begins-->
<ul>

<!--This loop should be passed with Labels to be filtered for Related posts-->
<b:loop values="data:post.labels filter (label => label.name in [&quot;Blogger Customizations&quot;,&quot;Blogger Tricks&quot;])" var="label">
        <li><a expr:href='data:blog.homepageurl + &quot;/search/label/&quot; + data:label.name'><data:label.name/></a></li>
</b:loop>

</ul>
<!--Un-ordered list tag begins-->

This loop takes care of linked lists and fits into all kind of posts. All we need to do is find the label name and added it in two places as highlighted in green.

Therefore, a third label can be added like below(yellow highlighted) and the code will look like,

<!--See related posts appear only if required-->
<b:if cond='data:post.labels any (label => label.name in [&quot;Blogger Customizations&quot;,&quot;Blogger Tricks&quot;,&quot;Custom Domains&quot;])'>
<b>See related posts:</b>
</b:if>

<!--Un-ordered list tag begins-->
<ul>

<!--This loop should be passed with Labels to be filtered for Related posts-->
<b:loop values="data:post.labels filter (label => label.name in [&quot;Blogger Customizations&quot;,&quot;Blogger Tricks&quot;,&quot;Custom Domains&quot;])" var="label">
        <li><a expr:href='data:blog.homepageurl + &quot;/search/label/&quot; + data:label.name'><data:label.name/></a></li>
</b:loop>

</ul>
<!--Un-ordered list tag begins-->

This will workout well and the number of lines of code is considerably reduced.
See related posts:

Comments

Feeds for you

How to secure your Google account and Blogger blog?

As a part of contributions to NCSAM, I am writing this article down on what all should we be aware of with respect to Google's security aspect and how to make sure your blog stays yours forever.
What is NCSAM? It's National Cyber Security Awareness Month which is observed during the month of October every year in America.

However, we all know cyber security is a world topic and is not limited to just the USA. So let me give some tips with respect to keeping the Google account safe and Blogger blogs safe from hackers.

As I secure my account, I hope you people catch up too.

In this blog post, I am going to tell about the following,
Securing your Google account.Securing your Blogger blog. Securing your Google account Since Blogger is also part of your Google account, let's first see what all we need to do to keep our Google account safe. Don't share your password to anyone.Keep changing your password every 60 - 90 days.Make sure your password is strong enough. Have at leas…

Blogger HTTPS for custom domain and Cloudflare

In BHF, there was a recent issue related to cloudflare where the browser screams the site is a phishing site. So I thought of writing up how does a service like cloudflare affect your blogger blog.

What is Cloudflare?

Well we have that written all over Wikipedia. Let's go on with why Blogger users look for Cloudflare.
Anciently Blogger users used cloudflare for one simple reason. HTTPS for custom domains.

So what happens when you introduce cloudflare into your domain?
DNS Redirect.
Your custom domain will be configured with the proxy info provided by cloudflare and when the request is hit, DNS redirect happens.
DNS redirect is bad for the site's health. A number of reasons, but the most important is that some browsers, when it detects a DNS redirection, it thinks that it is a phishing site.

What is a DNS redirect?

I am trying to explain this in easy terms. I'll try not to be too technical. When a custom domain URL is hit, usually the domain requests go to Name servers from w…

Blogger in Draft says "Try the new Blogger!"

It's been long time that I wrote something here. Interestingly there seems to be a new update in Blogger in Draft (https://draft.blogger.com).