Showing Related Articles to your Post

Please click on the title to go to the newly updated Widget (as of 9/21/2008).


protesto said...

Hoctro, I'm getting this error message:

"Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The reference to entity "callback" must end with the ';' delimiter."

Khong Co Ai said...

Hi Hoctro,

How to make this hack work after each post, on the main, archive, search page?

Hoctro said...


Oops,forget to do some text replacing on the JSON call, will fix this morning.

TonNet said...

At 9:44 AM Eastern Time I am still receiving the same message as Protesto just got it!

Hoctro said...

@Protesto: I fix the big, and tested. It should work. Thanks again.

@kca: You could do that having an array that will keep checking against known labels. I don't have any plan yet to do that. Let's try to see if this one works first.

I saw your comment on New Year. THanks and Happy New Year. I tried haf a day on your pagination suggestion but unfortunately couln't come up with anything.


Hoctro said...

@tonnet. I just fix it now. It should work. Thanks.

protesto said...

Doesn't working with any label longer than 3 words? That's too bad :( It's showing only one label's posts if you have multiple labels for a post, right ? :( Thanks for your help Hoctro, great hack anyway.

Hoctro said...

@Protesto, the hack support long labels now. Just don't label anything more than 21 words, but who'll do that? I'm happy with the introduction of a new for loop, as opposed to the brute-force ugly solution I came up with this morning.


Elaine Vigneault said...

If I want to limit the results to only 5 or 10 entries, how would I do that?

Chris said...

I have a strange situation. I have tried to incorporate this into my blog and the heading appears (the "Related Articles by Labels" one) but nothing ever appears under it. I have specified my blog in the code and I have all my posts labeled.

Hoctro said...

@kca & elaine,

I'll try to improve on your suggestions, prior to move on to a new hack. Thanks for your suggestions & patience.

@Chris: Don't forget this one is based on JSON callback, so you need to make sure you have your feeds enabled. I don't ruled out typo either. Pls leave here your test blog so I can see the source code & tell you what went wrong.


Hoctro said...

@kca & elaine, I added your comments. I'll explain more inside the post tomorrow.

Khong Co Ai said...


Thanks Hoctro, just woke up and found your up date...Great!
I will update my templates in the following hours and i will give you some feed back ^^

Hoctro said...

@KCA: I revised the widget so it is even more versatile. Check out the updat portion and re-cut-n-paste the code.

Ricardo Santos said...

Hi Hoctro!

Like Chris i installed the revised version on my blog but it doesnt display anything.

you can visit my blog at:

the widget is called "Artigos relacionados"


Alice said...

FYI, this person is giving away templates with your hacks already added. Do they have your permission to distribute your work?

Hoctro said...

@Ricardo, it looks to me like you host it somewhere else, using "". JSON callback only works with any site belongs to blogspot only!

@Alice: Protesto is one of the advanced hacker bleet. It's OK for him to re-distribute my hack, since he doesn't make any money for that service. It's really nice if him or any other people to ask for permission though. Usually I wouldn't say no, if it's for free for other people, like what I've been doing. But I know protesto fairly well, he's actually give some great suggestions.

Ricardo Santos said...

Sorry im not an expert on this stuff, when you say i hosted it somewhere else what do you mean? Im not using FTP or the new domain forwarding.


bhavin.marvadi said...

Hey Hoctro, great hack! Besides the great hack - the way you explain is so simple..... which makes it very easy for people (like myself) who know very less about JS and CSS to install hacks.... i also love the 3-column Minima templates!!

Keep up the great work!

Hoctro said...


Disregard the last comment!

I find out what happens. You don't have FEEDs on! Please look for instructions in the article (that I'll update shortly!

@bhavins: thanks!

Ricardo Santos said...

i do have feeds on that was the first thing i checked, i went hrough all the steps over and all is as it should be.

ill wait for the update.

Hoctro said...

@ Ricardo: you disppoint me! After we went through all this troubles and investigating, what happened was that you mispelled your own blog :)

var homeUrl3 = "";

it should be:

var homeUrl3 = "";

I should work now.

Ricardo Santos said...

What can i say in a situation like this one?? Sorry

How did i manage to forget those 2 letters i dont know.:D :D

Sorry for the nuisance


Hoctro said...

No problem! just kidding, if you hang around enough you'll know my style :)


Leon Ridge-Cooke said...

Hi Hoctro,

I have tried this hack out on my blog. I am using the new blogger feature (url masquerading or whatever it is called) and my blog address is The actual address is and this is the url that I have used in the hack. As a result, the hack almost works but for the label names themselves. If you look at you will see how only one or a few characters of the label is displayed. Any ideas?

Kind regards,


Hoctro said...

@Leon: seems like you are not yet installed the hack.

Anyway, I don't think it'll work, since the callback data would have links to the blogger's address. But then again, it might work if it knows how to redirect itself to your webpage.

protesto said...

Thanks for your nice comment above hoctro. I'm happy that you hack works more than 3 labels. Is it still showing post from only one labels? Whay if if your have more than one label?

protesto said...

Oh, you've already answer that :) It's working up to 3 hacks.

Why don't you distribute it as a wigdet, so people can install it only entering their blogspot name?

Hoctro said...

@protesto: you can have more than 3 labels. 3 is just the default.

i think if one has a blog, one is advanced internet users' kind a person, so changing values shouln't be a problem.

i didn't ask for people to code, just replaccing w/ values. How easier this could be than this??? :)

protesto said...

Yes, it's easy as it is, but wigdet is cooler ;)

Leon Ridge-Cooke said...

Hi Hoctro,

Good news. I have got it to work. I changed the variable from to and it now works. I have set it to work on item pages only.

Thanks for the hack.


Salman Siddiqui said...

not working for me...

I am using a custom template from

please hv a look..

Julius said...

it will be very cool to have it after each post such as the wordpress plugin that uses semantics thanks anyway

david said...

I had problems with escaping in the label names so I replaced:

var txt = document.createTextNode(label);


var txt = document.createTextNode(decodeURI(label));

Pankwood said...

Você tem este código para a versão do velho Blogger ?

Mad Money said...

sweet hack! How do you get the related post content to show before the labels and comments?

Eric Phuong said...

Unfortunately I could not apply your script to my blog,

The point that I do not understand is that you said " ...paste it in between any two "b:widget" tags". I did so, and it appeared on the header section...". Could you please help me to apply it to the end/bottom of my main post, please? Can I use it in a new page element (HTML/Javascript) which I have below the 'Main Post page?
Should I use any script such as type='text/javascript'...then closed with script tag before the closing /head tag as shown in one of the links you have when I apply this "Related Articles script or not ?
you can speak Vietnamese to me.
Thanks in advance and appreciated.

tom said...

hi dont know why, this hack dont show related labeled post at my blog. :(


Ruggero said...

Hey Hoctro! Very cool widget! I'm also having trouble with it, though. I can see it works perfectly well on your page, so I must be missing something. I followed your instructions to a T - RSS is on, labels are in use etc. When I copied the script in and went back to the Page Layout, I noticed I had 2 "Blog Post" Windows - one obviously being the new Widget, which I moved to below original "Blog Post" window. It appears in the right place, but no related articles get listed at all. I've checked the website address at
var homeUrl3, and it looks like this: var homeUrl3 = "";
I notice that instead of the " character, after clicking on save it automatically converts it to "&.q.u.o.t;" (I had to put the . in or else it doesn't show in this comment :) ) - is that a problem? I'd love to get this working - any ideas?

Trinity said...

Hi Hoctro, hope you read my comment and help me.. I use 3 columns page and the label's title on my widget is cut... can you tell me how to fix it?

Trinity from Rooms of
My Heart

Hoctro said...

@trinity: please be more specific. I couldn't see any odd things at your blog.

Dat Nguyen said...

Hanh Hanh duoc lam quen or

Akeel ur Rehman Faridee said...


i really appreciate your efforts. i found that in 'Related Articles' the post itself gets repeated. For Example if 'The Testing post' has three labels L1, L2 and L3 then in Related Articles Widget following is displayed:
'The Testing Post'
'The Testing Post'
'The Testing Post'

can we exclude the repetition and the appearance of post itself in 'Related Articles' ?

Second i just want to display the related articles (mean i dont want to display 'by labels').

Your efforts are always appreciated.

Vinayak said...

It's working great at my blog
Although I removed the attribution but I am writing a post acknowledging the same.
A big thanks!

J W said...

Great thank you! This is really a great works!!
By the way, I have one question here, after installed the hack and related articles, I am not able to modified any of the widgets using the blogger's widget(Page Element), in short, when I made any changes to the page element, it does not allow me to save! How to overcome this?

agblog said...

hi hoctro, it work for me too. i want to ask you something.
how to add adsense code above "Related Articles"(it means will be place on end post)that only show on post page?thx

ken_vs_ryu said...

Can I skip certain labels? Some of my labels are too general.

4ALL2ALL said...

A great post, thanks for sharing!

Dette said...

Hoctro - I love love LOVE this hack!! I was able install it in a snap - thanks for making it so easy for us newbies. ;)

If at all possible, I'd like to have a single page on my blog for just this - Related Articles by Labels/Categories. (So I can include it in my navigation menu). Of course, trying to include it as a post to get a permalink didn't work - would love to hear if you're able to post an update sometime.

You totally rock.

P.S. Couldn't find a button to link to you from my sidebar... I could just be missing it though.

City of Edinburgh Basketball Club said...


Love the hack. Do you know where I can adjust the style of the label headings? Is that in my CSS somewhere or in the hack?


tc said...

Hoctro - how would I remove the label names? Just display the list with no labels associated with them?

Holding It Together said...

Thank you, I love this! Awesome hack and thanks for sharing it.

Eaglface said...

I really love this hack. Thanks for sharing this.

But I found that only 25 posts are listed. Is there any limitation? I tried to change the value of maxNumberOfPostsPerLabel, but it does not work.

I saw your post about overcoming the limitation on the recent posts. Is there any remedy for this widget?