Displaying popular posts

You can attach images to each post using “featured images” by first enabling featured images for your theme using add_theme_support(‘post-thumbnails’), and get_the_post_thumbnail() to display images.

For example, to list 4 most commented posts with their featured image and title, you can do something like this:

$posts = get_posts(
    array(
        'posts_per_page' => 4,
        'order_by' => 'comment_count'
    )
);
foreach ($posts as $post) {
    get_the_post_thumbnail($post->ID)
    echo $post->post_title;
}

Read about WP_Query for more querying options. To get more advanced measurements, you may want to look into a plugin.