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.
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.
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.
Install YARPP directly from the WordPress plugin repository for free.