Custom JSON-LD script to add structured data to a WordPress site. After testing 4 highly ranked plugins I opted to write my own script to allow for complete customisation especially for custom post types like Events


View in Instagram ⇒

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 ⇒

Debugging pagination for a custom WordPress query – the “posts_per_page” value must match the value of “Blog pages show at most” under Settings > Reading, in the admin dashboard, else the last page in the pagination chain will break. If anyone knows how to programmatically avoid this issue drop it in a comment. Thanks

View in Instagram ⇒