You have to tell WP to generate this image sizes at first…
Use function add_image_size
and then “regenerate the thumbnails”:
add_image_size( 'custom-size', 220, 180, true ); // 220 pixels wide by 180 pixels tall, hard crop mode
Note “custom-size” string which could be anything you want.
https://developer.wordpress.org/reference/functions/add_image_size/
After that you can use the the_post_thumbnail
function with our custom defined image size “custom-size”:
the_post_thumbnail( 'custom-size' );
https://developer.wordpress.org/reference/functions/the_post_thumbnail/
More resources:
- http://wpshout.com/adding-using-custom-image-sizes-wordpress-guide-best-thing-ever/
- http://www.wpbeginner.com/wp-tutorials/how-to-create-additional-image-sizes-in-wordpress/
- http://code.tutsplus.com/tutorials/using-custom-image-sizes-in-your-theme-and-resizing-existing-images-to-the-new-sizes–wp-24815