Related posts with thumbnail
This is for those of you WordPressers who use YARPP (a.k.a. Yet Another Related Posts Plugin) and any of the excellent themes by WooThemes for your blogs. Especially if you’d like to spice up the plugin’s output a bit.
I use YARPP on almost all of my WordPress sites, and I’ve started tweaking the plugin’s output, inspired by another related-posts plugin that I saw on DavaoBase recently. That other plugin is called LinkWithin, and I like how it displays related posts with thumbnails. However, this plugin has almost no options, unlike YARPP, which has tons of it! (And I’m suspicious of LinkWithin’s way of inserting redirects — it’s as if, for whatever reason, they’re out to track the clicks…)
So, here’s something I’d like to share with those of you who’d like to keep using YARPP and display a thumbnail for every related post displayed on your blog posts. The screenshot here shows a post from my food blog — take a look at the bottom part (in the red square) with the “You might also like…” heading.
YARPP has a set of sample templates that let you control the visual output of the plugin. Instead of settling for the default settings, you can have a higher degree of control over how the related posts are displayed by using the YARPP templates. Simply copy one of those templates (located in wp-content/plugins/yet-another-related-posts-plugin/yarpp-templates) into your current theme’s directory, modify that template to your heart’s desire, then activate it via the YARPP settings page.
The custom YARPP template
Create a template file in your theme directory that will contain the related-posts code. For our purposes, let’s name this file yarpp-template-thumbs.php (N.B., for YARPP to recognize the template, it has to be prepended by “yarpp-template-”). The code I wrote for DavaoDeli.com is the following:
<?php /*
YARPP Template for use with post thumbnails
Requires WordPress 2.9+ and the WooThemes framework
Author: Blogie
*/ ?>
<?php if ($related_query->have_posts()) : ?>
<div class="relthumbs">
<h5 class="relposts">You might also like...</h5>
<ul class="relposts-thumbs">
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
<li class="relitem">
<?php woo_image('key=image&width=80&height=80&class=relimg'); ?>
<span class="thumb-ttl"><?php the_title(); ?></span>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php else: ?>
<p>No related posts at the moment.</p>
<?php endif; ?>
Line 7 above declares the start of the special WordPress Loop that calls the related posts (handled by the plugin). Line 16, on the other hand, is the one that displays the thumbnails. It’s a built-in function in all WooThemes.com themes with WooFramework version 3+.
For those of you who don’t use WooThemes, don’t despair. There is a YARPP template included with the plugin that you can use. It’s called yarpp-template-thumbnail.php. Just copy that template to your current theme directory, activate the template via the YARPP settings page, and make sure to follow the instructions contained in this page from the WP Codex.
(If you’re using a child theme, place the thumbnail-related WordPress functions in the child theme’s functions.php template.)
That’s it! I hope you’ve found this useful.






Hey Blogie. Thanks for the mention! Yes, we have been long-time users of LinkWithin, which is a great plugin. But you're right: there are limited options, and the link redirect might be counted as "bounces" off the site. I'm still looking for other plug-ins that will create the same output. If all else fails, I'll try your version of YARPP with thumbnails.
I recommend that you do use YARPP – it's much more configurable and everything's "in-house", so to speak.