How to Add Multiple Post Thumbnails / Featured Images in WordPress – WPSaviour

By WP Saviour •  Updated: 08/11/20 •  3 min read

Just lately one among our readers requested if there was a approach so as to add a number of put up thumbnails or featured photographs in a WordPress put up. By default, most WordPress themes include built-in help for featured photographs which makes including put up thumbnails actually easy. Nonetheless when engaged on customized initiatives, you would possibly want so as to add a second featured picture to a put up. On this article we’ll present you tips on how to add a number of put up thumbnails / featured photographs in WordPress.

Very first thing you’ll want to do is set up and activate the A number of Put up Thumbnailsplugin. After activating the plugin, you’ll want to add the next code in your theme’s features.php file. You possibly can add it anyplace within the file so long as you’re doing it proper. Learn our information on tips on how to paste snippets from the online.

1

2

3

4

5

6

7

8

9

if (class_exists('MultiPostThumbnails')) {

new MultiPostThumbnails(array(

'label' => 'Secondary Picture',

'id' => 'secondary-image',

'post_type' => 'put up'

 ) );

 }

When you add that, now you can add a secondary featured picture to your put up. All it’s important to do is Edit an present put up or create a brand new put up. It is best to see a secondary featured picture meta field proper after the featured picture field in WordPress put up edit space.

multiple-thumbnails-wordpress-3253274

Regardless that you possibly can add a secondary featured picture in your WordPress admin, it is not going to show in your website till you configure your theme. All you’ll want to do is add the next code inside your put up loop the place you wish to show it. This may very well be in your single.php (for single posts), archive.php (just for archive pages), and so on.

1

2

3

4

5

6

7

8

9

When you try this, you’re finished. Your theme is now able to show a number of featured photographs. That is the way it seemed like once we examined it:

multiple-featured-images-5575817

You possibly can repeat this course of so as to add as many featured photographs as wanted. You can too prolong the help to different customized put up sorts as an alternative of simply posts.

Including New Thumbnail Sizes

If for some motive you’ll want to change the thumbnail dimension for the secondary featured picture, then you are able to do so by creating further picture dimension in WordPress. Don’t overlook to regenerate thumbnails or new picture sizes. After this you possibly can name the brand new picture dimension in your a number of put up thumbnails code. For instance, in case you created a brand new picture dimension with the title secondary-featured-thumbnail you’ll add this code in your template:

1

2

3

4

5

6

7

8

9

gp-4654555 as-5239021

WP Saviour

I am a WordPress specialist. My mission is to help you create beautiful websites with ease!