How to Get Most Commented Posts with Thumbnail


Sponsored Links




There are so many way to attract visitor on your WordPress blog, the one of them is show most popular post on your sidebar or footer, beside that fact in order to help your visitors finding your best content.

Let’s me share “How to get most commented posts along with their related thumbnail“, This trick need little bit code to be written on your themes files. I will show you how to do this. The first time, open your sidebar.php or footer.php or whatever files with your favorite editor. Then write down this code

<?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?>
	<?php while ($popular->have_posts()) : $popular->the_post(); ?>
	<?php $justanimage = get_post_meta($post->ID, 'thumbnail', true);
		if ($justanimage) { ?>
	<img src="<?php echo get_post_meta($post->ID, "Image", true); ?>" alt="<?php the_title(); ?>" />
	<?php } else { ?>
	<img src="http://an-alternative-image.jpg&quot; alt="" />
	<?php } ?>
	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php endwhile; ?>


That I mean, on this code above, the thumbnail is taken from custom field “thumbnail”. You can change it depend on your thumbnail custom field. Thanks for Alex Denning for share this tricks

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net

How to Get Most Commented Posts with Thumbnail / WordPress Tricks

There are so many way to attract visitor on your WordPress blog, the one of them is show most popular post on your sidebar or footer, beside that fact in order to Read More

Get most commented posts with thumbnails - WpRecipes.com : Daily

display their most commented posts on their blog’s sidebar. In this recipe, I’ll show you how you can get most commented posts along with their related thumbnail. Read More

Plugin Most Commented Posts | Blog Wordpress

- Configure how many articles (posts) to display. Check out how the Most commented posts widget looks like: Note that this plugins will get the thumbnail of your featured Read More

Most Commented Post in Wordpress Without Plugin - Php Tutorials

count&posts_per_page=5'); ?> Most Commented Post Read More

Most Commented Posts The Right Way in WordPress - WPShout.com

Kristof, I was just working on a post about using the post thumbnail function For this, we followed my own advice to get most commented posts the right way: [] Read More


7 Responses to How to Get Most Commented Posts with Thumbnail

  1. dNoxs says:

    thanks for tricks…

    I have bookmarks it

  2. Pingback: Display Recent Comment with Gravatar without plugin # WordPress Tricks & Tips

  3. saç ekimi says:

    Hi all
    very nices post.
    thank admin

  4. Yes , i agree that showing latest comments attract more visitors and keep their interest. thanks for the code.

  5. it’s not working for my blog
    plz help me

    waiting for ur anwser

  6. Puneet says:

    You need to check with your code. Your code display the most commented posts. If I want to display the comments and not the post, what modifications I need to make.

  7. Excellent article, thanks very much for this information.
    Happy to have found this post.It’s interest.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>