WP LOGBOOK

Little adventures building sites with Wordpress…

Add WP Post Thumbnail

with 4 comments

Most of the wordpress available themes in the industry do not have this support provided by the latest WP installation, that is 3.0 Beta and the current widely used WP installation is 2.9.2 version.

You need to add…

add_theme_support( 'post-thumbnails' );

…inside functions.php (Theme Functions file) of your theme.

After you saved the file, notice there’s a change in your Posts admin panel and you will see something like:

Next is for you to show the image. You can place this tag anywhere but the best place will be in the loop.

But before you do that, you need to add another line of code in the functions.php right after the first one because you need to define the size of the image. Eg.

add_theme_support( 'post-thumbnails' );
add_image_size( 'index-post-thumbnail', 205, 155, true );

Now then you can place this tag like this …

<?php the_post_thumbnail('index-post-thumbnail'); ?>

…anywhere inside the loop of the post.

Important note. The name you use must tally at both the tag and the code in functions.php, eg. if you use index-post-thumbnail, then both must be the same.

That means you can have different sizes with different call names.

Hope this helps! =D

Advertisements

Written by Yahya Ayob

April 24, 2010 at 12:03 am

Posted in coding, tutorial, WordPress

Tagged with

4 Responses

Subscribe to comments with RSS.

  1. hi

    Can you tell me where abouts I should put the

    add_theme_support( ‘post-thumbnails’ );

    in the functions.php

    also when you say in the loop – do you mean loop.php

    thanks

    marcia

    marcia

    July 14, 2010 at 7:58 am

    • Hi Marcia. You can find detail information on The Loop here at WordPress Codex.

      You can put the code at any place in the function.php. For me, I normally place it at the top after the <?php

      Yahya Ayob

      October 15, 2010 at 12:42 pm

  2. I want say great job, and i have question how to put zero border for link image ??

    sam

    October 15, 2010 at 10:06 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: