WordPress without plugins. WordPress: Related posts without using a plugin

Hello, dear friends and guests of the blog site! Today we’ll talk about how to do SEO optimization of a WordPress website independently and without using third-party plugins. If you are interested in this question, then I ask you to read this material to the end. Since at the end of this article you will receive a link to download the necessary files with working codes that can significantly improve and speed up your site. Interesting? Then, let's go...

There are a lot of plugins for SEO optimization of WordPress. And you've probably heard about them and know a lot of them?! If not, then this is not a problem! I have already written about these plugins in my previous materials (you can read it by typing the plugin you are interested in in the site search!), and if suddenly the search does not find it, then write in the comments and I will definitely write about it in the future!

But today, as you probably already guessed, we are not talking about SEO plugins for the site, but quite the opposite...

How to avoid using a plugin on a website when optimizing it? Now I’ll tell you and at the end I’ll let you download very necessary, one might even say necessary for a blogger using the WordPress engine, files with codes that will help protect and speed up the site.

But first, let's make sure that your site requires SEO optimization...

How to check a site before optimization?

There is a special service for these purposes and it also offers you to download and install on your resource a plugin for SEO site optimization - Clearfy

Enter your website address in the bar and check it completely free of charge. After checking, you will see that your site is not optimized at all and is quite vulnerable to attackers. This is what the picture will look like on your monitor:

Of course, you can download and install this plugin on your website to optimize your resource, but I will repeat myself and say that today we are working to optimize our website without using any plugins. This is so as not to load the engine! Let's continue...

Now let's see what happens to the site after I applied special codes in the site files to optimize it:

Yes, I completely forgot to say that this plugin is offered to us not completely free, but we need to buy it!!! Do you need this? I don't!

If you also don’t need to buy something, what can you do yourself and for free?! Then let's move on...

How to optimize your WordPress site yourself without a plugin?

This is done very simply and will be accessible to each of you. Even if you don’t understand the HTML and CSS structure of your resource!

I think that each of you will find the path to the root folder of your site and to the theme folder? Is not it?! If not, then ask your hoster, he will definitely tell you!

Here is a link to download the files I promised at the beginning of the article, using which WordPress optimization will not be a problem for you!

Inside there will be a small description that will help you, and if you have any questions, write in the comments and I will definitely try to help you!

Good luck and prosperity to everyone, and I say goodbye... Until we meet again!

Hello dear readers. Similar entries on the site, like breadcrumbs, refer to ways to automatically link pages to each other. They usually look like a vertical or horizontal block (See the picture below), in which several posts are located, selected from the database according to certain criteria. The block can be implemented either using plugins or by inserting PHP code into the functions.php file. Today I would like to show you the second method, i.e. using clean code without using plugins.

PHP code

As a rule, the selection of similar posts in WordPress occurs by headings (categories). Below is the function that needs to be inserted into the functions.php file. The function is provided with detailed comments.

Function related_posts() ( global $post; $titleRelated = "Read also";//Name of the block of similar posts $countPosts = 3;//number of posts displayed // getting all categories to which the post belongs $categories = get_the_category($post ->ID); if ($categories) ( // forming an array of IDs of all categories $categoryIds = array(); foreach ($categories as $category) ( $categoryIds = $category->term_id; ) // getting similar posts from bases in random order $relatedPosts = new WP_Query(array("cat" => $categoryIds, "posts_per_page" => $countPosts, "post__not_in" => array($post->ID), "orderby" => "rand" )); // output a block of similar posts if ($relatedPosts->have_posts()) ( ?>