Back to Top

How To create custom size thumbnail in WordPress

WordPress is the best solution for bloggers. You can easily post your content in WordPress with images.Almost every good blog post needs an image.An image will give the reader an instant idea of what the post is about and the image will draw the attention of readers as well. WordPress makes it easy to add an image to your post, control default image sizes, make minor edits to that image, and designate a featured image for your post.

Almost all WordPress themes support Post Thumbnails and You can use post thumbnails for your images, but sometimes you want to make changes in the thumbnail size as can’t use built in thumbnail functionality of WordPress.

Post Thumbnail or Featured image is a great option in WordPress to allow the user to .Here is a quick tutorial on how to get it to work within a theme.

Open theme functions.php file within the theme folder and add the following code :

Above line of code will create the different size of post thumbnail rather than default ones and the single-post-image argument specifies that to use the image size you defined rather than the default size of the image.

single-post-image creates thumb as 75px width and 83px height and you can specify any of the name and the sizes which fit with your theme.You can add multiple add_image_size functions and can create multiple thumbnails.The third parameter in add_image_size function is optional is “true” means to crop the image and save it as a separate image.You would like to read about how to Disable Post Revisions in WordPress.

To get it to display the custom image sizes so that you have to add following line of code within the loop into the pages. The function the_post_thumbnail is used to display thumbnail and argument will be the name that has been given within the function.

To add the featured image on your page, open file and add the following code within the loop:

That’s it. Now you can upload an image from admin panel of WordPress and its display image with.

I hope you have enjoyed this tutorial. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Have you tried above code in your theme? Do you have any query about custom thumbnail? Let me know via comment section.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to use JavaScript Promise API?

Posted on 7 years ago

Bhumi

Custom Directives in Angular JS

Posted on 9 years ago

Bhumi

How to use Session in Joomla

Posted on 12 years ago

Bhumi