About a week ago I started running the Related Entries plugin here. If you aren’t directed to this site either through a news aggregator or a search engine, there’s a good chance that you haven’t seen this plugin in action because I only have it running on individual archive pages. To get a feel for what it does, take a look at my initial post about the Smart Archives plugin. Notice the possibly related section in the menu. I chose this particular post because it’s a somewhat apropos example given its topic and it does well to highlight the accuracy of the plugin. The accuracy though isn’t always as good as it could be; there are a lot of posts where it just chokes and either returns nothing or posts that are totally unrelated. Time permitting, I’m going to dissect the source at some point and see if I can game it (i.e., modify the way that it scores posts for relevance) to give more deference to the content of the post; as it stands now, I think it looks only at the title of the posts if you supply no keywords. In the context of this plugin, keywords are user-defined, one word descriptions that help the plugin to return more meaningful results, but for obvious reasons, namely time, there’s no way in hell I’m going to add keywords to all of my entries (or even just to those whose titles don’t accurately reflect their content).
I installed this plugin with some trepidation, fearing that the server hit would be too expensive, but surprisingly, it’s pretty negligible (granted, we aren’t talking about searching through that many posts; I’m not sure how well it scales up).
Be Careful Where You Call It
As usual, before I take something live on this website I test it pretty heavily. While putting this plugin through the motions I came across some rather odd behavior which took me a few minutes to nail down. To sum it up, the function call to this plugin must be placed after the infamous WP loop, else you’ll get the dreaded no related posts.
I initially called the function after the individual archive section of the menu, which runs through the loop, so there were no problems there. After playing around with it some, I decided that the results should be displayed before the individual archive section. This meant that the function would be called before any iteration of the loop (because of the way my markup is structured, the menu is built before the rest of the page; if that were not the case, then there would be no problem because the content section of these archive pages goes through the loop). To avoid having to change the structure of my markup, I decided to simply throw in a dummy loop before I called the plugin.