image flash

Related Posts Picker

A WordPress Plugin by ThoughtLab

March 11th, 2011

We wanted to show related posts on our blog, so we started off using the built-in functions of WordPress. Then, we noticed that many of the posts that WordPress decided were related had absolutely nothing to do with anthing… So, we tried some plugins. There were plugins which used related and similar tags, some which used categories, but they all seemed to be very mechanical. The lists they generated were all obviously computer generated. Then, we had an idea… why don’t we have the option to decide for ourselves which posts really are related? Several lines of code later, the Related Posts Picker plugin was born! WordPress will give you a list of posts that it thinks are related to the one you’re updating, and you  are able to tell WordPress which posts really are related. You can configure the number of posts you have to choose from, and the maximum number of automatically selected posts that will show if you don’t choose any.

So, go check it out, and if you find it useful, then download it here.

To use the plugin in your theme, simply add the function: <?php rpp_related_posts(); ?> wherever you would like your list to be shown.

You will need to tag your posts and save them before it can come up with a good list of options to choose from.


6 Responses to "Related Posts Picker"
Glyn Holton says: March 19th, 2011 at 4:33pm

This looks like a great plug-in. I am going to play around with it and may give more feedback. I do have some immediate questions.sugestions …

1. You indicate that the plug-in will “automatically selected posts that will show if you don’t choose any”. I might not chose any because none on the list are related. Rather than have the plug-in display a list of posts I know are not related, it would be nice if the user had the option to have the plug-in not appear on pages where he/she chooses no posts from the list.

2. Are the user’s selections reciprocal? For example, if I just created a new post called XYX, and I tell the plug-in that post ABC is related, then the plug-in will indicate on the XYZ post that ABC is related, but will it also indicate on the ABC post that XYZ is related?

3. It would be nice to be able to manually add posts to those to be displayed in the event there are related posts that the plug-in doesn’t identify as possibly related.

Anyway, thanks for a great plug-in.


Nichol says: March 25th, 2011 at 12:09pm

This looks like a wonderful plugin. I cans see the related posts in my post area while I’m writing a post but they are not displaying? Why?


Florence says: June 5th, 2011 at 7:01am

Same as Nichol. Till I’m on my administrator panel, I can choose which related post I want to add, it’s perfect. But as soon as I go on the front-page, user-end, I only see “related post” added in the sidebar (where I have inserted a Text widget with ‘ inside) but no related posts appear under. What’s the problem ?


Pam says: July 29th, 2011 at 10:52am

We love this plugin but we’re wanting to choose “unlimited” from the dropdown for how many possible posts it will show, but it’s stuck on 25. Am I missing something or is this a bug? Thanks!


Nick Ciske says: August 8th, 2011 at 9:55am

FYI- multi word tags (e.g. “tag name”) aren’t handled correctly by the plugin. You need to slugify the tag before passing it to get_posts().

Just spent an hour trying to figure this one out…

My quick hack was to change line 73 to:
if($tags) $related_tags = str_replace(‘ ‘,’-',implode(‘,’, $tags));

Not perfect, but it’s now working — until I hit a tag with an apostrophe ;-)


Nick Ciske says: August 8th, 2011 at 10:04am

Here’s a real fix:

function fixtags(&$value, $key){
$value = sanitize_title_with_dashes($value);
}

if($tags){
array_walk($tags,”fixtags”);
$related_tags = implode(‘,’, $tags);
}