Single post thumbnail image in wordpress

For adding WordPress Post Thumbnail Image to every post, you need to first edit the wordpress theme functions.php file and add this below code:

add_action( 'after_setup_theme', 'bn_theme_support' );

function bn_theme_support() {
add_theme_support( 'post-thumbnails' ); // This line of code will add featured image option in post writting area.
add_image_size( 'post-thumb', 150, 150, true ); // This line of code is image size in width and height.

Now open index.php file or other related files that contain the main content and add this below code to display WordPress Post Thumbnail Image somewhere in those file:

<?php if ( has_post_thumbnail() ) : the_post_thumbnail('post-thumb'); endif; // This line of code will display Thumbnail Image ?>

Leave a Reply

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

Solve : *
30 + 30 =