Press "Enter" to skip to content

WordPress: show similar articles without plugins

0

Introduction

In this article, I propose a PHP function to display similar articles on your WordPress site.

Following the hacking of the plugin Yuzo Related Post that I used on the site, I finally decided to do without plugin to do that.

To have a demo, I invite you to browse the site to see the result.

The code

In the file functions.php of your WordPress theme add the function below:

The display is based on the Bootstrap.

In the theme’s article display file, call the function with the following code:

Conclusion

If you have some knowledge in PHP, it’s easy to customize the function and have something you manage the code for.

I’m not against plugins, which is the strength of WordPress, but for some features, it is still better to do things even that which reduces the risk for your site.

A function of 60 lines (it could do less) will replace a plugin of almost 200 files without really knowing the content and how your site is affected by it.



Related Posts


It looks like you're using an adblocker.
We use ads to keep our content free. Please support us by turning off your adblocker.