How to show most commented posts with thumbnail in WordPress
Here is another handy WordPress snippet to show most commented posts with thumbnail. Add below code to your template and it will display most commented posts with thumbnail.
<?php $popular = new WP_Query('orderby=comment_count&posts_per_page=10'); ?> <?php while ($popular->have_posts()) : $popular->the_post(); ?> <?php $thumb_img = get_post_meta($post->ID, 'Image', true); // get an image if ($thumb_img) { ?> <img src="<?php echo get_post_meta($post->ID, "Image", true); ?>" alt="<?php the_title(); ?>" /> <?php } else { ?> <img src="http://alternative-image.png" alt="" /> <?php } ?> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php endwhile; ?> |