How to: Related Posts with Thumbnails in WordPress without Plugins

How To Display Related Posts with Thumbnails in WordPress without Plugins
[php] <?php $orig_post = $post; global $post; $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args=array( ‘tag__in’ => $tag_ids, ‘post__not_in’ => array($post->ID), ‘posts_per_page’=>5, // Number of related posts that will be shown. ‘caller_get_posts’=>1 ); $my_query = new wp_query( $args ); if( $my_query->have_posts() ) { echo ‘<div id="relatedposts"><h3>Related Posts</h3><ul>’; while( $my_query->have_posts() ) { $my_query->the_post(); ?> <li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a></div> <div class="relatedcontent"> <h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3> <?php the_time(‘M j, Y’) ?> </div> </li> <? } echo ‘</ul></div>’; } } $post = $orig_post; wp_reset_query(); ?> [/php] Once you pasted this code in your theme file, the query uses the first tag of the post to fetch related posts. In the above example code, Six related posts are displayed. You can change this number.
Display Related Posts with Thumbnails in WordPress without Plugins
(adsbygoogle = window.adsbygoogle || []).push({}); Though there are links to categories or tag available in the sidebar/footer, their accessibility is less when compared to the links posted just after the end of the content. Related posts will increase the user engagement of the website and it will also thrive to few additional page views for the website.
16 Best WordPress Login Page Plugins
WordPress.org
You can specify number of related posts to display, start date, categories to show on and to include, top text, style settings, default image URL. You can select type of relation — categories, tags, categories and tags, random or custom taxonomies. You can specify where to display related posts — choose page type (main or single), post type and select categories. You can turn off automatic appending to the end of post and use <?php get_related_posts_thumbnails(); ?> php tag in the Loop of your theme. Related Posts thumbnails sidebar widget is also available. You can use [related-posts-thumbnails] shortcode in the post body.
BloggingLove
This is Ravi Chahar, the person behind this website. I have been working in the field of web development and designing for years now. WordPress interests me and I help people to explore it. I am a social person who knows the value of human bonds. The blogging era has just begun. I have the aim to provide an effective way to build a blog. If you have an eagerness to crave the knowledge about WordPress then I am here to help you. Know More About Me.
Best Plugins to display Related Posts with Thumbnails in WordPress
This is one of the best WordPress plugin so far, wait!! I’m not the only one who is saying this when Matt Cutts (Google webspam team’s head) listed out few powerful plugins to display related posts, he mentioned this plugin at the top. You can do a lot with this plugin – It has option to display list style posts or posts with thumbnails. Moreover, it comes with a related posts widget, which you can embed in sidebar or footer, cool huh!. Get the plugin from here. There are numerous options which you can customize as per your need such as number of posts to display, where to display (page, posts or homepage), with or without thumbnails, horizontal or vertical display or manual display (use of single line of code in your template where you want to show the posts).
How to Add Image Thumbnails to Related Posts in WordPress
    have_posts()) : $related_query->the_post(); ?>                                 <a href="” rel=”bookmark” title=””>                                     <a href="” rel=”bookmark” title=””>                        $files = get_children(‘post_parent=’.get_the_ID().’&post_type=attachment&post_mime_type=image’); if($files) : $keys = array_reverse(array_keys($files)); $j=0; $num = $keys[$j]; $image=wp_get_attachment_image($num, ‘large’, false); $imagepieces = explode(‘”‘, $image); $imagepath = $imagepieces[1]; $thumb=wp_get_attachment_thumb_url($num); ?>
Show Related Posts with Thumbnails in Genesis without Plugin
We used both tags and categories in this tutorial to display related posts. The way our script works is pretty simple. First, it finds the tags a post is assigned to then tries to find other posts using that same tag. If it gets enough posts, it stops. Otherwise it checks the category for more posts to finish out the total number of related posts we are going to show. It does a very good job of building the related posts. Here we go…
WordPress.org
No huge widget with hundreds of options. This plugin is based on the well-known WordPress default widget ‘Recent Posts’ and extended to display more informations about the posts like e.g. thumbnails, excerpts and assigned categories. And it provides more options to build custom-taylored posts lists.
How to Show Related Pages in WordPress With /Without Plugin
On the Setting page, the first two sections can be ignored, and you only need to scroll down to ‘Display Options for your website’ section. Under Automatically Display option, check the box before Pages and lever the boxed before Posts and Media blank. Then select to show related pages as a list or show pages’ thumbnails.
WordPress.org
You can specify number of related posts to display, start date, categories to show on and to include, top text, style settings, default image URL. You can select type of relation – categories, tags, categories and tags, random or custom taxonomies. You can specify where to display related posts – choose page type (main or single), post type and select categories. You can turn off automatic appending to the end of post and use <?php get_related_posts_thumbnails(); ?> php tag in the Loop of your theme. Related Posts thumbnails sidebar widget is also available. You can use [related-posts-thumbnails] shortcode in the post body.
How to Add Popular Posts with Thumbnails to WordPress Blog (without Plugins)
The reason why it is named as “Popular posts” is that we are going to get the list of posts having higher comment count in the decreasing order. Comments are one another factor to find out the user engagement and quality of the post. We can customize the number of posts to be filtered under Popular Post category. It is also possible to order the list of the items randomly.
9 Best Audio Player Plugins for WordPress
WordPress.org
I spend a significant amount of my free time maintaining, updating and more importantly supporting this plugin. Those who have sought support in the support forums know that I have done my best to answer your question and solve your problem. If you have been using this plugin and find this useful, do consider making a donation. This helps me pay for my hosting and domains.
HostOnNet Blog
It checks the tags assigned to the current post and then it fetches the posts linked to those tags. We have used an orderby attribute, which would ensure that the posts would not be fetched in an any particular order. This would be useful to show different related posts on the posts assigned to the same tags.