WordPress Related Posts

I was reading some blogs today, and noticed that the “Related Posts” feature was actually quite handy. I found some related articles that I was actually interested in reading. With that in mind, I decided to add this feature to my blog. There are actually many options available for this type of task. That’s what’s so awesome about WordPress: there are so many plugins available. And though I haven’t yet tried, I’m sure that writing one is a cinch, too. Anyway, I chose one of the plugins and activated it. Setup took 2 seconds. But it wasn’t quite right.

It didn’t have a heading above it. That’s just simple HTML: I went and edited my template so that “Related Articles” appears above the list. Another issue was that the links had titles with the prefix “Permanent Link: “. In my opinion, that’s a given for my URLs. So I went into the PHP file, and removed that redundancy. Also, it continued to list 5 bullet points, even if less than 5 related posts were found. This is what I changed to fix that (if you’re looking at the plugin’s code, I think you can see what this means):

if ($title) {
$output .= $before_title .'<a xhref="'. $permalink .'" rel="bookmark" title="' . $title . '">' . $title . '</a>' . $after_title;
}

Maybe this will help someone out there.

Reflection: This even helped myself as reference later on, when I upgraded the plugin as part of my WP 2.0 upgrade project.

Leave a Reply