WordPress Wednesday: Efficient Related Posts

* Update: I now recommend [YARPP](http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/) for related posts instead. Read why in my post [My top 5 WordPress plugins](http://matthewman.net/2010/07/29/my-top-5-wordpress-plugins/)

WordPress is a great blogging platform. And because it’s built on PHP, it’s possible to include lots of dynamic code that gets evaluated and run whenever one of your website’s readers loads a page.

Too many such dynamic elements, though, and it can seriously degrade your site’s performance, especially if those elements require complex database access. A case in point is any plugin that calculates related posts ‘on the fly’. The more posts your blog has, the longer any such calculation would take. And given that every reader will be shown the same related posts information, recalculating that information on every page view doesn’t make much sense.

A caching plugin (for example, WP-SuperCache) would help, but it makes more sense to maintain the related posts links in the database, and only recalculate the network of links when posts are created or edited.

That’s the intention behind Efficient Related Posts. Every time you create a blog post, the plugin will store links to other posts — so when you view the post page, no expensive recalculations have to be made.

Of course, if you calculated related posts only for new posts, the only links that would be created would end up going to older posts. Efficient Related Posts gets round that problem by selectively recalculating other posts’ links too. So if you create post A and the plugin determines that it’s related to posts B, C and D, those three posts’ related links will get re-evaluated.

In a blog with thousands of entries, there’s a possibility that the evaluation loop could cause some serious delays. At least by containing those delays to the admin side, your readers will gain the benefit of the related links without any delays in their preparation.

Author: Scott Matthewman

Formerly Online Editor and Digital Project Manager for The Stage, creator of the award-winning The Gay Vote politics blog, now a full-time software developer specialising in Ruby, Objective-C and Swift, as well as a part-time critic for Musical Theatre Review, The Reviews Hub and others.

One thought on “WordPress Wednesday: Efficient Related Posts”