WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the post thumbnail feature to show portfolio work, so for example <?php the_post_thumnail(); ?> the problem is I want to show a particular width of image only, which is 640 but because my pieces are website they have varying heights.

I'm using this code to create the images: add_image_size( '640', 480 ,true ); // 640x480 image size but it's specifying the height how can I ONLY specify the width??


Ps. I know I could use CSS, but I want to actually create images at 640 wide and not use any timthumb stuff etc. Thanks

share|improve this question

That is one strange add_image_size() call. You are missing size's name and mixing up string with integer. And you specify crop mode, when you actually need resize mode. Try this:

add_image_size( 'portfolio-shot', 640, 9999 );

Then fetch it with:

the_post_thumbnail( 'portfolio-shot' );

This should properly register image size under portfolio-shot name in soft-resize mode to width 640px. Note that (unless there were changes in recent WP versions, not sure) new size will be effective only for new uploads.

See this tutorial for excellent writeup on using related functions:

New in WordPress 2.9: Post Thumbnail Images

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.