Quick Tip: How to Use the New
videos

Quick Tip: How to Use the New “Post-Thumbnail” Feature in WordPress 2.9

Up until the release of WordPress 2.9, setting up “post-image” support for your blog was a bit more tedious a task than it really needed to be. Luckily, that’s no longer an issue. I’ll show you how to get setup in this four minute video quick tip.

Step 1. Edit your Functions.php Page

// Enable support for post-thumbnails

add_theme_support('post-thumbnails');

// If we want to ensure that we only call this function if
// the user is working with WP 2.9 or higher,
// let's instead make sure that the function exists first

if ( function_exists('add_theme_support') ) {
	add_theme_support('post-thumbnails');
}

Step 2. Insert the Image Tag into your Loop

Within the “if have_posts()” loop, simply place this piece of code anywhere you like. At that point, WordPress will insert an image tag onto the page accordingly. Please note that you’ll have access to a “wp-post-image” class that you may then work with to format/style the image.

<?php the_post_thumbnail(); ?>

Add Comment

Discussion 78 Comments

Comment Page 2 of 2 1 2
  1. Vish says:

    Thanks for the overview!

    vishalpanjwani@hotmail.com

  2. Chris says:

    I don’t know why in my case when I’m doing this tutorial my dashboard after refresh any thing like page content, navigator is white, there are not anyhing. I’m sorry my english.

  3. メール友達がすぐに作れちゃうサイト!完全無料だからはじめてでも安心・簡単に作れちゃいます。趣味別、年齢別など豊富なジャンルから探せるからメール友達が作りやすい

  4. Came across this page with a Google search query string of: “how to use wp post thumbnail”.

    Just wanted to say this little video at the top provided both an awesome visual and audio explanation/demonstration me exactly what I needed for my project.

    For those of you that are checking whether a post has a thumbnail or not, and displaying a default image if one doesn’t exist… Search the WP Codex for the function/reference “has_post_thumbnail()”.
    http://codex.wordpress.org/Function_Reference/has_post_thumbnail

    //This must be in one loop

    if(has_post_thumbnail()) {
    the_post_thumbnail();
    } else {
    echo ”;
    }

  5. Came across this page with a Google search query string of: “how to use wp post thumbnail”.

    Just wanted to say this little video at the top provided both an awesome visual and audio explanation/demonstration me exactly what I needed for my project.

    For those of you that are checking whether a post has a thumbnail or not, and displaying a default image if one doesn’t exist… Search the WP Codex for the function/reference “has_post_thumbnail()”.
    http://codex.wordpress.org/Function_Reference/has_post_thumbnail

    //This must be in one loop

    if(has_post_thumbnail()) {
    the_post_thumbnail();
    } else {
    echo ”;
    }

  6. Came across this page with a Google search query string of: “how to use wp post thumbnail”.

    Just wanted to say this little video at the top provided both an awesome visual and audio explanation/demonstration me exactly what I needed for my project.

    For those of you that are checking whether a post has a thumbnail or not, and displaying a default image if one doesn’t exist… Search the WP Codex for the function/reference “has_post_thumbnail()”.
    http://codex.wordpress.org/Function_Reference/has_post_thumbnail

    //This must be in one loop

    if(has_post_thumbnail()) {
    the_post_thumbnail();
    } else {
    echo ‘<img src=”‘.get_bloginfo(“template_url”).’/images/img-default.png” />’;
    }

  7. eirik says:

    Any possibility of using post thumbnail, when using video as the source not an image?

  8. Jeremy says:

    Great tutorial, very simple, thank you.

Comment Page 2 of 2 1 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.