How to Display Related Posts in WordPress

How to Display Related Posts in WordPress

Currently, there are a startling number of webmasters choosing to display a long list of related posts after all posts. In this sense, adding related posts to a WordPress site has been prevailing among people with its positive effect on decreasing bounce rate and increasing Google AdSense income.

Besides that, attaching related posts to certain posts is also a great way to increase page views so as to boost community engagement. At this place, we would like to demonstrate how it is easy to add related posts in WordPress with a good collection of suggestions included.

How to Display Related Posts on a WordPress Site Manually?

Objectively speaking, it doesn’t require much technical knowledge to put related posts onto a WordPress site. And all you need to do is to copy and paste the below code to the single.php file in your theme. Note that you can place the following code at anywhere inside the single.php file.

<?php
$postTags = wp_get_post_tags($post->ID);
if ($postTags) 
{
    $tagIdCollection = array();
    foreach($postTags as $postTag) 
        $tagIdCollection.push($postTag->term_id);

    $parameters=array
    (
        'tag__in' => $tagIdCollection,
        'post__not_in' => array($post->ID),
        'showposts'=>4,
        'caller_get_posts'=>1
    );

    $postQuery = new wp_query($parameters);
    if( $postQuery->have_posts() ) 
    {
        while ($postQuery->have_posts()) 
        {
            $postQuery->the_post();
?>
            <a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php
        }
    }
    wp_reset_query();
}
?>

By the way, it is possible to specify your thumbnail image’s size, and you only need to go to the functions.php file before inserting the following shortcode. Pay attention that the below “300” and “150” can be replaced with your exact dimensions.

add_theme_support(‘post-thumbnails’) 
set_post_thumbnail_size(300,150,true)

How About Adding Related Posts with WP Plugins?

One of the big advantages that WordPress has over other average software is that it offers all sorts of plugins that are free to install and use. At this place, there are many hassle-free WP plugins that enable you to display related posts in WordPress with little effort. If you are still confused after reading the “Installation” area of each plugin, you can refer to this illustrated plugin installation tutorial.

Yet Another Related Posts Plugin
As a lightweight plugin, Yet Another Related Posts Plugin (also called as YARPP) has been widely-used to showcase a list of related posts on a WordPress site on the basis of a unique algorithm. More than that, this customizable plugin can also display custom post types and pages to the correspondent entry, bringing more relevant content to the front of your readers.

More importantly, Yet Another Related Posts Plugin so far has been improved a lot with a bunch of features added. To name a few, this WP plugin now supports customized thumbnail layout, related content from multiple websites and content list’s detailed reporting. Special attention should be paid that it requires WordPress v3.3 or higher versions, MySQL 4.1 and PHP 5, etc.

Website URL: https://wordpress.org/plugins/yet-another-related-posts-plugin/

Related Posts - Yet Another Related Posts Plugin

CP Related Posts
CP Related Posts, as a long-awaited plugin, enables you to add related articles to your WordPress site manually. Alternatively, this useful plugin also empowers you to display related posts by using a powerful algorithm that helps to identify the terms in the post title, content and abstract.

Above all, CP Related Posts can help you specify how many related posts will be displayed on your site with a well-designed layout. In the meantime, this versatile plugin also allows you to identify the information attached to the related posts, such as author, tags, and title. Plus, it offers you a simple way to decide the percentage of correspondence between certain two posts.

Website URL: https://wordpress.org/plugins/cp-related-posts/

Related Posts - CP Related Posts

Related Posts via Categories
As its name implies, this Related Posts via Categories plugin works to display your related posts list through categories. Besides that, this easy-to-use plugin can automatically add a full list of related posts after any single post or specified post types. Within the settings, there are many available options for post-type selection, order, display and exclusion, etc.

In terms of the system requirement, Related Posts via Categories supports the 3.2 or higher versions of WordPress, and it requires jQuery v1.6 or higher versions. As for user satisfaction, this popular plugin has been given high ratings of 4.3 out of 5 stars with overwhelming recognitions and applauses. Note that, it supports both English and Japanese scripting languages.

Website URL: https://wordpress.org/plugins/related-posts-via-categories/

Related Posts - Related Posts via Categories