Currently set to Index
Currently set to Follow

Get the Official WPSaviour App Now!

Best WordPress PluginsBlog

How to Add Multiple Post Thumbnails / Featured Images in WordPress

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.

Featured and secondary featured image in post edit area

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
<?php
if (class_exists('MultiPostThumbnails')) :
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');
endif;
 ?>

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:

Adding Multiple Post Thumbnails or Featured Images in WordPress

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
<?php
if (class_exists('MultiPostThumbnails')) :
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', NULL,  'secondary-featured-thumbnail');
endif;
?>

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlogTips

Top 5 free payment gateway plugins for WordPress in India (2020)

Beginner’s GuideBlogTips

Best WooCommerce International Payment Gateways for WordPress in 2020

Best WordPress PluginsBlog

WordPress 5.4 Will Add Lazy-Loading to All Images

Beginner’s GuideBlog

How to Add a Preloader Animation to WordPress (Step by Step)

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.