Home / comment / Most commented with post thumb
  • How to Most commented with post thumb

    no thumbnail sorry: Most commented with post thumb

    Adding this PHP code to your wordpress theme will display a listing of the most commented posts and will include a thumbnail.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?php $popular = new WP_Query('orderby=comment_count&amp;posts_per_page=5'); ?>
    <?php while ($popular->have_posts()) : $popular->the_post(); ?>
    <?php $justanimage = get_post_meta($post->ID, 'Image', 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" alt="" />
    <?php } ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php endwhile; ?>
    

    ( WordPress codex functions, hooks, in this snippet. )

    posts_per_page, the_title, the_permalink, query, get_post, have_posts, the_post, get_post_meta, wp,
  • Nice post, thnx.. But your code in a problem;

    Line 5 >>>Problem>>> ( $ p o s t – / > I DNominal >>> donot pr. >>> ( $ p o s t -> ID 

    • Thanks for pointing that out I removed the slash /
      Cheers.