Family Encyclopedia >> Electronics

How to Display Related Posts in WordPress: Reduce Bounce Rate and Boost AdSense Earnings

As a WordPress expert with years of experience optimizing sites for engagement and revenue, I know bounce rate is a key metric. It tracks the percentage of visitors who leave after viewing just one page—a direct hit to your AdSense earnings and overall performance. Adding related posts tackles this head-on: it lowers bounce rates, drives more pageviews, and increases revenue, all in one go.

We'll cover two reliable methods to implement related posts in WordPress: a manual code approach without plugins, or a feature-rich plugin option. Choose what fits your site best.

Display Related Posts Without a Plugin

Add this proven PHP code to your theme's single.php file, right after the main content loop where you want related posts to appear. It pulls posts based on shared tags for relevance.

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
    echo '<h4>Related Posts</h4>';
    $first_tag = $tags[0]->term_id;
    $args = array(
        'tag__in' => array($first_tag),
        'post__not_in' => array($post->ID),
        'posts_per_page' => 5,
        'caller_get_posts' => 1
    );
    $my_query = new WP_Query($args);
    if ($my_query->have_posts()) {
        echo '<ul>';
        while ($my_query->have_posts()) {
            $my_query->the_post();
            ?>
            <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
            <?php
        }
        echo '</ul>';
    }
    wp_reset_postdata();
}
?>

Adapted from community expert MichaelH for modern WordPress compatibility.

Display Related Posts With a Plugin: YARPP

Yet Another Related Posts Plugin (YARPP) is my go-to for effortless, high-performance related content. It analyzes titles, content, tags, and categories to score and display truly relevant posts or pages.

  • Advanced Algorithm: Customizable scoring based on titles, content, tags, and categories. Set your relevance threshold for perfect matches—more posts when abundant, fewer when sparse.
  • Flexible Templates: Full control over display with the new 3.0+ template system.
  • Performance Cache: Pre-computed results for blazing speed, a huge upgrade from older versions.
  • RSS Integration: Add related posts to RSS and Atom feeds with tailored options.
  • Exclusions: Block specific tags or categories from results.
  • Posts & Pages: Show related posts, pages, or both.

Install YARPP directly from the WordPress plugin repository for free.