wordpress child theme twentyeleven showing featured images

I am trying to make a child theme out of twentyeleven, and so far so good as far as the css goes, but now I want to display a featured image and I don’t know how.

I added this to my functions.php;

Read More
// add featured images 
add_theme_support('post-thumbnails');
set_post_thumbnail_size(500, 200);

Which means featured images are enabled but it still won’t show up. I have used featured images in other, premade, layouts so I know I’m not doing anything wrong as far as setting the image goes. I think I have to add a bit of code in my single.php file or maybe my post.php file? I found this piece of code;

if (has_post_thumbnail()) {
    the_post_thumbnail();
}

and put in my (empty) single.php file of my child theme but it didn’t work. What piece of code do I need and where do I need to put it to show these featured images?

Related posts

Leave a Reply

1 comment

  1. <?php echo get_the_post_thumbnail($post_id, 'large', array('class' => 'class_here')); ?>
    

    or if you want to link to another size:

    <?php 
    if ( has_post_thumbnail()) {
        $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
        echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" class="classes_here" >';
        the_post_thumbnail('large');
        echo '</a>';
    }
    ?>
    

    More in codex WP

    Hope this helps

    /Paul