Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Show Related Posts in WordPress

Keep visitors reading by showing similar articles under each post.

WordPress2 min read12 steps7 screenshots
  1. More engagement. Readers who liked one post often want another.
  2. More page views. Visitors stay longer and see more pages.
  3. Better SEO. Internal links help search engines find your content.
  4. More traffic. Links to other posts bring people back.

Method 1: WordPress.com built-in feature

If your site is on WordPress.com, you do not need a plugin.

  1. Log in to your WordPress.com dashboard.
    The WordPress.com dashboard
  2. Go to Settings, then Reading (or Settings, then Writing, depending on your plan). Turn on Related posts and save.
    The related posts setting

Method 2: A plugin

For a WordPress.org site, use a plugin. Popular choices:

  • Yet Another Related Posts Plugin (YARPP)
  • Related Posts for WordPress
  • Inline Related Posts

Pick one with easy setup, good design control and good speed.

Set up YARPP

  1. Go to Plugins, then Add New. Search for YARPP, install and activate it.
    The YARPP plugin
  2. Open the new YARPP menu. The important settings are:
    - The Pool. Which posts and pages can be shown as related.
    The pool settings

    - The Algorithm. How YARPP decides what is related. For example, the match of titles, content, categories and tags, and the number of results.
    The algorithm settings

    - Automatic Display Options. Where the list shows, and the heading and layout.
    Automatic display options
  3. Click Save Changes, and open a post to see the result.
    A related posts preview

Method 3: Custom code

If you know PHP, you can show related posts from the same tags. Do this in a child theme.

  1. Create a child theme folder with a style.css file (see our guide on child themes).
  2. Add this code to the child theme functions.php:
function get_related_posts($post_id) {
    $tags = wp_get_post_tags($post_id);
    if (!$tags) return array();
    $tag_ids = wp_list_pluck($tags, 'term_id');
    $args = array(
        'tag__in'        => $tag_ids,
        'post__not_in'   => array($post_id),
        'posts_per_page' => 3,
    );
    return get_posts($args);
}
  1. In single.php (copied into the child theme), show them below the post:
<?php
$related = get_related_posts(get_the_ID());
if ($related) {
    echo '<h3>Related posts</h3><ul>';
    foreach ($related as $post) {
        echo '<li><a href="' . get_permalink($post) . '">' . get_the_title($post) . '</a></li>';
    }
    echo '</ul>';
}
?>

Quick recap

  • WordPress.com has a built-in switch.
  • YARPP is an easy plugin for self-hosted sites.
  • Custom code gives full control.