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' ); } ?>

Share This Post

Post Comment