Change Post Thumbnail Size in WordPress



Today I am explaining some tricks to change post thumbnail size in WordPress theme. If you have enabled post thumbnail for your theme, you will get that default size of these thumbnails are not like as you want. If you want all of your post thumbnail to be same size in your theme, then you can set the size in functions.php file of that theme.

// 150 pixels wide by 150 pixels height
set_post_thumbnail_size( 150, 150 );
// 150 pixels wide by 150 pixels height, hard crop mode
set_post_thumbnail_size( 150, 150, true);

If you want to have different image sizes for archives, category pages, and custom post types, you can set them directly within the template using tag, like below:

<?php the_post_thumbnail('thumbnail'); ?>

You can use following options:


the_post_thumbnail();                  // without parameter -> Thumbnail

the_post_thumbnail('thumbnail');       // Thumbnail
the_post_thumbnail('medium');          // Medium resolution
the_post_thumbnail('large');           // Large resolution

the_post_thumbnail( array(150,150) );  // Other resolutions

For more information and details you can check WordPress Codex.