Is there any way to auto-generate a 150x150 thumbnail image for each post based on the post's selected featured image? This would be preferable as opposed to manually going into each post, copying the images 150x150 image URL and pasting it thumb custom field.

1 Answer 1


Inside your post loop you can do;

 if ( has_post_thumbnail()) {
 echo get_the_post_thumbnail($post->ID, 'thumbnail');

This first checks for the existence of a featured image and if so it will display one at your default 'thumbnail' size as set in your settings/media options.

This would also work within your loop;

 if ( has_post_thumbnail()) {

This would work (but can be used outside of your loop);

 $id = get_the_ID();
 echo get_the_post_thumbnail($id, 'thumbnail');

Beyond that there are other functions to help you customize sizes should that not achieve what you want. However the above defaults to 150x150.

Let me know how you go.

  • So this will create a new record in the postmeta table?
    – keruilin
    Commented May 19, 2012 at 15:44
  • @keruilin No. The thumbnails have already been generated for you when you upload an image, Full Size (original image size) then several other sizes are generated automatically by WP. Using the above you are simply telling WP to show a thumbnail "here" with "here" being wherever you insert the call into your theme file and the thumbnail declaration which specifies which size of the image you want returned.
    – Adam
    Commented May 19, 2012 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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