Show Excerpts and Post Thumbnail Twenty Eleven Theme

Adding post thumbnails and excerpts to Twenty Eleven theme is not much different than how they would be added to Twenty Ten.

The first step is to create a functions.php file for your child theme if you don’t already have one and add this to it. This adds our own custom size thumbnail of 140px X 140px.

I strongly recommend installing and running Ajax Rebuild Thumbnails plugin after completing this tutorial. It will create a new image size for each featured image. You can uninstall it after it’s finished.

// This sets the dimensions for the thumbnails displayed on the homepage
	add_image_size('excerpt-thumbnail', 140, 140, true);

The next step we need to tell our theme to display excerpts instead of the full post. Copy content.php to your child theme directory and open it. Find this block of code around line 35

		<?php if ( is_search() ) : // Only display Excerpts for Search ?>
		<div class="entry-summary">
			<?php the_excerpt(); ?>

Change it to this.

		<?php if ( is_search() | is_home() ) : // Edit this to show excerpts in other areas of the theme?>
		<div class="entry-summary">
		<!-- This adds the post thumbnail/featured image -->
			<div class="excerpt-thumb"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
		<?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?></a></div>
			<?php the_excerpt(); ?>

By adding | is_home() to the if statement it tells our theme to display excerpts on the homepage. I find doing it this way allows more control over which areas display excerpts and which display the full post.

Just below that you can see we’ve added the post thumbnail, the size of this is controlled by what we added to functions.php in the first step.

Now just save those two files and add a featured image to your posts and you’ll see post thumbnails with excerpts.

76 thoughts on “Show Excerpts and Post Thumbnail Twenty Eleven Theme

  1. Joel


    Thanks for the tut on excerpts. I implemented everything above, step by step, but it somehow throws my layout off. The first post/excerpt/thumbnail looks great, but everything else spills out.

    Any suggestions?

  2. Pingback: Show Excerpts and Post Thumbnail Twenty Eleven Theme |

  3. Pingback: Imagen destacada en ‘Twenty Eleven’ | Sin orden ni concierto

    1. Zeaks

      Open content.php and read line 37, remove is_home() || from the line. I’ve commented throughout the theme so things like this are easy to edit.

      I may add an option to control where excerpts are shown in the future, and well as post thumbnails.

      1. Arnie Rowland

        Thanks. I had found that and done so. However, my home page has 1 full post followed by 9 summary posts. If I change the ‘Blog pages show at most’ setting to 1, then the category and other pages that should have excerpts only have 1 excerp…

  4. Arnie Rowland

    I can see that wasn’t too clear. Having made the change as you suggested, the Home page now shows 1 full post and 9 summary posts. The Blog pages show at most’ setting is 10. If I change that setting to 1, then the Home page shows only 1 full post (the desired outcome), BUT other pages (categories, tags, etc.) also show only 1 summary.

    The desired outcome is that only one full post on the Home page, and up to 10 summary posts on other pages (categories, tags, etc.) You can observe this behavior at:

    1. Zeaks

      I see what you want to do now. This is not a theme specific issue, it’s how WordPress works. Whatever number of posts you select to show, will also be used for categories too. I will look for a way around this and post back if I find one.

  5. Myrto

    Hi there,

    i wonder if you could help me with this thumbnail problem i have: thumbnail image shows only for the first post

    I realised that I have a strange problem when I try to share a post in facebook.
    From all my posts, only for the first post I created the thumbnail image shows for when I try to share the link in facebook, via a sharing plugin (i.e. shareThis, or sociable), or even when I directly paste the link in facebook myself.
    For the rest of posts I created I get no image at all.
    I should add here that thumbnail image shows when I share pages.
    The problem is only with posts.

    I have build a child theme for twenty eleven, and when I removed it the problem was still there.

    Then I removed twenty eleven and replaced it with Kubrick theme, and the problem was still there.

    I would be grateful if you could shed some light on this


    1. Zeaks

      The way this works is you have to set a featured image for a post, then it’ll display as a thumbnail. The other way to do it would pull the first image from the post and use that as a thumbnail. Not sure if you can use both ways. I’ve never tried it the other way but a quick Google search came up with this.

      Open functions.php and add this to it.

      function catch_that_image() {
        global $post, $posts;
        $first_img = '';
        $output = preg_match_all('/<img.+src=['"]([^'"]+)['"].*>/i', $post->post_content, $matches);
        $first_img = $matches [1] [0];
        if(empty($first_img)){ //Defines a default image
          $first_img = "/images/default.jpg";
        return $first_img;

      Set a default image in case your post doesn’t have an image. (3rd line from the bottom)

      Then in the loop (content.php) just before

      <?php the_excerpt(); ?>

      use this to display the thumbnail.

      <?php echo catch_that_image() ?>
  6. Pablo

    Thanks for the explanation, it is really clear. What I’m trying to do is to show on the homepage the latest post as full post, and the following ones as excerpts. I found in some places that they do this directly in index.php, but I’m having trouble implementing it with the get_template_part function. Any pointers?

  7. Adam

    Great article that solved my problem with twenty eleven excerpts. However I notice that your replacement text includes a line of code that is not part of the swap:

    <!-- .entry-summary -->

    I guess for 100% accuracy you should either remove it from the second code block or add it to the first…

    Thanks for the assistance!

    1. Adam

      Hmm, I bracketed my code excerpt with the “code” tag but it disappeared. It’s the last line in the “change it to this” code block that is superfluous (and might mess up an unwary cut-and-paster).

  8. Pingback: WordPress Tutorial For Beginners: Additional Screen Options In...

  9. Pingback: SEO Enterprise-WordPress Tutorial For Beginners: Additional Screen Options In New Post/Page Screens

  10. Pingback: » WordPress Tutorial For Beginners: Additional Screen Options In New Post/Page Screens

  11. Pingback: A Free wordpress newsletter » WordPress Tutorial For Beginners: Additional Screen Options In New Post/Page Screens

Leave a Comment

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