Writing a lightweight related content function for WordPress using tags to match content

Strangely, WordPress doesn’t ship with it’s own related content feature so there are a number available to download and use from the plugin directory. However, in my experience, most of these are quite resource-hungry, largely due to the fact that they build up the list of related content by string matching. This is a very expensive process and depending on the number of posts the script has to match against can lead to a slowdown in the database.

I’ve opted to write my own related content plugin using WordPress tags. Generally, a post should not have more than 5 tags attached to it. This makes the matching process much faster and less intensive on the database as tags are only ever matched against other tags attached to posts and never against the content of the posts themselves which could be lengthy.

Now this has the potential to get out of hand as tags can be easily entered by post authors leading to duplicates and unnecessary tagging which can then lead to poor relative matching. However, any professional organisation will have a publishing process and part of that should be for authors to avoid adding tags before checking if a suitable one already exists in the system.

View in Instagram ⇒

Comments are closed.