Blog

See what I am talking about...

Adding thumbnail support to your WordPress theme

28 July

Yea WordPress! Starting in version 2.9, thumbnail support is built into the code, which means that instead of doing all the hard work, WordPress has done it for you! For the most part anyway…

It’s a pretty simple process.

1. Add a line of code to functions.php

add_theme_support('post-thumbnails');

2. Define the size of the thumbnails – you have a couple options. You can hard crop it, which is what I have done in the example below (add ‘true’ to the end of the dimensions), or you can resize the box. Box resizing shrinks an image without distortion until it fits inside the “box” you’ve specified with your dimensions.

set_post_thumbnail_size( 100, 100, true ); // 100 pixels wide by 100 pixels tall, hard crop mode

Together this will look like:

3. Add the code to your template

That’s it! Now when you login to your wp-admin panel scroll down – on the right side under ‘Categories’:

Click on ‘set thumbnail’ and you get this box:

Be sure to select ‘Use as thumbnail’ and then ‘save’. Then close the window with the X on top right.

Here’s an example of it used on one of my sites:

No comments yet.

Leave a Reply