How to Display Related Posts in WordPress Without Plugins

WordPress is one of the most popular engines and plugins are written for it for every taste and for almost any task.. I think everyone, who developed a site that has a lot of content thought about how to get users to stay on the site and read articles further. To keep users on the site, it is necessary for them to offer articles of interest to them. The plugin solves this problem perfectly related post thumbnails but this plugin has a lot of settings, which are not always needed., and if you already have a lot of plugins installed, then adding a few more can really slow down your site. It was for these reasons that I began to dig on the Internet and look for a solution to the problem of displaying similar blog posts using simple code., no extra settings.

One of the reasons for writing this article was that, that the plugin that I used to use had a conflict in working with another plugin and displayed instead of four pictures 16. All in all, the story was not good.

Another reason why you need to be able to write plugins yourself, is the creation of premium themes and selling them on the Internet on sites such as themeforest.net or for your clients. One of the most important requirements of themeforest when developing a theme for a site is its support and development.. If the plugin you were using stopped working, then explain to those who have already bought your theme, why don't they work, won't lead to anything good. If you wrote your plugin for example, similar articles by all rules WordPress API and embed it in your theme, it is unlikely that it will be necessary to deal with improvements in the future and just like that it will not stop working.

And now, in fact, about similar entries with thumbnails

Paste the code on the page single.php in the right place.

After inserting the code, similar articles and pictures of different widths will be displayed on your page. It remains only to correct the css styles.

Making a plugin based on code

Now if you need a plugin, you can make it from all this, to use it on your projects. First, in the plugins folder, create a folder my-related-post-thumbnail and add a file to it related-post-thumbnail.php. In the file you need to place the code of the created plugin:

To insert code into a template, you need to add code, for example, in single.php, to the right place.

That's all for today, good luck with development.


Купить хостинг WordPress
/* WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal