Related post thumbnails in Simply related Posts widget

	function my_related_posts_thumbnail( $title, $post, $instance ) {
		if ( has_post_thumbnail( $post->ID ) ) {
			$title = get_the_post_thumbnail($post->ID).$title;
		}
		return $title;
	}
	add_filter( 'simply_related_posts_title', 'my_related_posts_thumbnail', 10, 3 );

The Snippets Story

If you are using my Simply related Posts plugin, you might want to have related post thumbnails. The code above is simply adding the post-thumbnail before the related post titles, if it exists. It implements the simply_related_posts_title filter, to add thumbnails to the printed title. Of course, you can add not only thumbnails, but any other kind of information to the title, by using that filter.

Works with version Simply related Posts 1.2 and later.

Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *