August 13, 2006

Related posts from your blog

Few people had expressed interest in finding related posts from their blog automatically. If you have lot of posts in archives, it is indeed difficult to find the ones that are related to the current post.

By tweaking my previous hack to display related posts from Blogosphere, I have come up with another version to do this. This time, I have tweaked it to bring out only the relevant posts or None. I use the "Search in title" operation in Google blogsearch to find the earlier posts with titles that have atleast 2 non-trivial words from the current post's title. I hope this will encourage more people to try this hack.

For plugging-in this feature to your blog, add the following piece of code after the <$BlogItemBody$> tag.


<ItemPage>
<script language="Javascript"
src="http://www.anniyalogam.com/scripts/relatedposts-blog.php?
url=<$BlogItemPermalinkUrl$>&blog=<$BlogURL$>">
</script>
</ItemPage>


This will display the related posts right after the Post body as you see below (only in post pages). Please note that it won't display anything if there are no related posts. You could also place in any other location in your template that you like to.

9 comments:

  1. Thanks a lot for this hack, i was looking for it since 1 year. :)

    Now we miss just one extention of this hack....: "Related video"

    Thanks in advance Ramani ^^

    KCA

    ReplyDelete
  2. D'oh! I keep getting this message:

    "Please correct the error below, and submit your template again.
    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 value of attribute "src" associated with an element type "script" must not contain the '<' character. "

    Any suggestions?

    Thanks in advance.

    Loup

    ReplyDelete
  3. How do you do related posts in blogger beta?

    ReplyDelete
  4. Kris,

    I haven't yet got this working in Beta. I will see if I can.

    ReplyDelete
  5. this might work in new blogger
    put this data:post.urlat the place of
    $BlogItemPermalinkUrl$

    ReplyDelete
  6. is possible change de words related posts by others???

    I have a blog in spanish :)

    Thanks

    ReplyDelete
  7. Hi, Ramani. I love your blog, you're a genius! Thank you so much for all your hacks!

    I've translated this hack to Portuguese, here:

    Hack de Posts Recentes para Blogger Clássico

    My readers have been asking for this, and thanks to you, I can help them. Obrigada! :)

    I'l be translating some other hacks and I'll let you know about them.

    Once again, thanks, thanks, thanks!
    A big hug for you, from a Brazilian girl!

    ReplyDelete
  8. Hi Ramani,
    I was wondering if your going to update this hack, or if there's a way
    to use it with the new blogger? thank you

    ReplyDelete
  9. Joana,

    I don't think I will make this hack work with new Blogger. If I ever do, I will announce it in my blog. Just subscribe to my feed.

    ReplyDelete

Dear Visitor,

All the hacks in this blog are proven to work. If some hack doesn't work for you, please re-read the instructions carefully and re-check the code.

-Ramani