How to use featured image in wordpress

To use featured image in wordpress, You must add this line in your functions.php file

if ( function_exists( ‘add_theme_support’ ) ) {

add_theme_support( ‘post-thumbnails’ );

set_post_thumbnail_size( 150, 150 ); // This is default Post Thumbnail dimensions


You can change this dimension here or from the admin

Path to change the dimension from admin:

Setting -> Media -> Thumbnail size

To add more thumbnail sizes :

if ( function_exists( ‘add_image_size’ ) ) {
add_image_size( ‘large-thumb’, 450, 259, false ); //300 pixels wide
add_image_size( ‘small-thumb’, 118, 80, true ); // (cropped)

To use the new thumbnail image:

<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'small-thumb' ); } ?>

Bansal Sumit

To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

You may also like...

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.