This simple plugin makes it easy for you to display posts related to the one the visitor is viewing with just a shortcode.
It will show the featured image from the post, along with the title of the post underneath as an H3. Both the image and the title will link to the blog post.
It displays posts based on Yoast’s primary category feature. It’ll look for the primary category of the post that’s being viewed, and then display other posts with that same primary category.
To show 4 related posts, you would enter this shortcode where you want your posts to show. This is a great addition to your sidebar or to a widget area below each post (such as “You might also like:”) to keep visitors clicking around on your site.
[show_related_posts]
If you want to show more or less than four, you can add the number of posts to the shortcode. For example, to show the 3 posts you’d put:
[show_related_posts posts_per_page="3"]
There is no styling included in this plugin, which means it will match your blog perfectly. It will use the same H3 font and style that is already in use on your blog.
Since this plugin is based on Yoast’s primary category, you must have Yoast installed and activated in order for it to work. You do not need the premium version of Yoast.
You can change the style too if you’d like to with the css class related-posts. For example, if you wanted to make the images smaller, and align them to the left, you could add this:
.related-posts img {
width: 200px; /*Or however wide you want them to be*/
float: left; /*Or right*/
}
To change the size or look of the titles, you could add:
.related-posts h3 a {
font-size: 20px; /*Or however big you want them to be*/
color: #000; /*Or whatever hex code you'd like*/
}