Wordpress Multiple Post Thumbnail Image

Multiple Post Thumbnail Images in wordpress

Adding WordPress Multiple Post Thumbnail Image is similar to add WordPress Single Post Thumbnail Image. You just need to add an extra line of code to do this in theme functions.php file.

For adding wordpress multiple post thumbnail image in your theme, add this below code in functions.php file:

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.
add_image_size( 'medium-thumb', 300, 300, true ); // This line of code is image size in width and height.
add_image_size( 'large-thumb', 450, 450, true ); // This line of code is image size in width and height.
}

To display various WordPress Post Thumbnail Image in your website, add this below code in index.php file or other related files that contain the main content:

<?php if ( has_post_thumbnail() ) : the_post_thumbnail('post-thumb'); endif; ?>

OR

<?php if ( has_post_thumbnail() ) : the_post_thumbnail('medium-thumb'); endif; ?>

OR

<?php if ( has_post_thumbnail() ) : the_post_thumbnail('larg-thumb'); endif; ?>

Published by

Emdad Khan

I am Emdad Khan, A WordPress Theme Developer and Author of BN Web Design Website. A full time Freelancer on WordPress Theme Development & Optimization as well as blogger.

Leave a Reply