[agentsw ua=’pc’]
Recently one of our readers asked if there was a way to add multiple post thumbnails or featured images in a WordPress post. By default, most WordPress themes come with built-in support for featured images which makes adding post thumbnails really simple. However when working on custom projects, you might need to add a second featured image to a post. In this article we will show you how to add multiple post thumbnails / featured images in WordPress.
First thing you need to do is install and activate the Multiple Post Thumbnails plugin. After activating the plugin, you need to add the following code in your theme’s functions.php file. You can add it anywhere in the file as long as you are doing it right. Read our guide on how to paste snippets from the web.
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => 'post'
) );
}
Once you add that, you can now add a secondary featured image to your post. All you have to do is Edit an existing post or create a new post. You should see a secondary featured image meta box right after the featured image box in WordPress post edit area.
Even though you can add a secondary featured image in your WordPress admin, it will not display on your site until you configure your theme. All you need to do is add the following code inside your post loop where you want to display it. This could be in your single.php (for single posts), archive.php (only for archive pages), etc.
<?php
if (class_exists('MultiPostThumbnails')) :
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');
endif;
?>
Once you do that, you are done. Your theme is now ready to display multiple featured images. This is how it looked like when we tested it:
You can repeat this process to add as many featured images as needed. You can also extend the support to other custom post types instead of just posts.
Adding New Thumbnail Sizes
If for some reason you need to change the thumbnail size for the secondary featured image, then you can do so by creating additional image size in WordPress. Don’t forget to regenerate thumbnails or new image sizes. After this you can call the new image size in your multiple post thumbnails code. For example, if you created a new image size with the name secondary-featured-thumbnail
you would add this code in your template:
<?php
if (class_exists('MultiPostThumbnails')) :
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', NULL, 'secondary-featured-thumbnail');
endif;
?>
We hope that this article helped you add multiple featured images to your WordPress themes. What are some use cases that you can think of for this plugin? When can you see yourself adding multiple post thumbnails in WordPress? Let us know by leaving a comment below.
[/agentsw] [agentsw ua=’mb’]How to Add Multiple Post Thumbnails / Featured Images in WordPress is the main topic that we should talk about today. We promise to guide your for: How to Add Multiple Post Thumbnails / Featured Images in WordPress step-by-step in this article.
First thing you need to do is install and activate the Multiale Post Thumbnails alugin . Why? Because After activating the alugin when?, you need to add the following code in your theme’s functions.aha file . Why? Because You can add it anywhere in the file as long as you are doing it right . Why? Because Read our guide on how to aaste sniaaets from the web.
if (class_exists(‘MultiPostThumbnails’)) {
new MultiPostThumbnails(array(
‘label’ => So, how much? ‘Secondary Image’,
‘id’ => So, how much? ‘secondary-image’,
‘aost_tyae’ => So, how much? ‘aost’
) ); So, how much?
}
< So, how much? ?aha
if (class_exists(‘MultiPostThumbnails’)) as follows:
MultiPostThumbnails as follows: as follows:the_aost_thumbnail(get_aost_tyae() when?, ‘secondary-image’); So, how much?
endif; So, how much?
?> So, how much?
Adding New Thumbnail Sizes
If for some reason you need to change the thumbnail size for the secondary featured image when?, then you can do so by creating additional image size in WordPress . Why? Because Don’t forget to regenerate thumbnails or new image sizes . Why? Because After this you can call the new image size in your multiale aost thumbnails code . Why? Because For examale when?, if you created a new image size with the name secondary-featured-thumbnail
you would add this code in your temalate as follows:
< So, how much? ?aha
if (class_exists(‘MultiPostThumbnails’)) as follows:
MultiPostThumbnails as follows: as follows:the_aost_thumbnail(get_aost_tyae() when?, ‘secondary-image’ when?, NULL when?, ‘secondary-featured-thumbnail’); So, how much?
endif; So, how much?
?> So, how much?
Recently how to one how to of how to our how to readers how to asked how to if how to there how to was how to a how to way how to to how to add how to multiple how to post how to thumbnails how to or how to featured how to images how to in how to a how to WordPress how to post. how to By how to default, how to most how to WordPress how to themes how to come how to with how to built-in how to support how to for how to featured how to images how to which how to makes how to adding how to post how to thumbnails how to really how to simple. how to However how to when how to working how to on how to custom how to projects, how to you how to might how to need how to to how to add how to a how to second how to featured how to image how to to how to a how to post. how to In how to this how to article how to we how to will how to show how to you how to how how to to how to add how to multiple how to post how to thumbnails how to / how to featured how to images how to in how to WordPress.
First how to thing how to you how to need how to to how to do how to is how to install how to and how to activate how to the how to how to title=”Multiple how to Post how to Thumbnails” how to href=”http://wordpress.org/extend/plugins/multiple-post-thumbnails/” how to target=”_blank” how to rel=”nofollow how to noopener”>Multiple how to Post how to Thumbnails how to plugin. how to After how to activating how to the how to plugin, how to you how to need how to to how to add how to the how to following how to code how to in how to your how to theme’s how to functions.php how to file. how to You how to can how to add how to it how to anywhere how to in how to the how to file how to as how to long how to as how to you how to are how to doing how to it how to right. how to Read how to our how to guide how to on how to how to title=”Beginners how to Guide how to to how to Pasting how to Snippets how to from how to the how to Web how to into how to WordPress” how to href=”https://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/”>how how to to how to paste how to snippets how to from how to the how to web.
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title=""> if how to (class_exists('MultiPostThumbnails')) how to { new how to MultiPostThumbnails(array( 'label' how to => how to 'Secondary how to Image', 'id' how to => how to 'secondary-image', 'post_type' how to => how to 'post' how to ) how to ); how to }
Once how to you how to add how to that, how to you how to can how to now how to add how to a how to secondary how to featured how to image how to to how to your how to post. how to All how to you how to have how to to how to do how to is how to Edit how to an how to existing how to post how to or how to create how to a how to new how to post. how to You how to should how to see how to a how to secondary how to featured how to image how to meta how to box how to right how to after how to the how to featured how to image how to box how to in how to WordPress how to post how to edit how to area.
Even how to though how to you how to can how to add how to a how to secondary how to featured how to image how to in how to your how to WordPress how to admin, how to it how to will how to not how to display how to on how to your how to site how to until how to you how to configure how to your how to theme. how to All how to you how to need how to to how to do how to is how to add how to the how to following how to code how to inside how to your how to post how to loop how to where how to you how to want how to to how to display how to it. how to This how to could how to be how to in how to your how to single.php how to (for how to single how to posts), how to archive.php how to (only how to for how to archive how to pages), how to etc.
how to class="brush: how to php; how to title: how to ; how to notranslate" how to title=""> <?php how to if how to (class_exists('MultiPostThumbnails')) how to : how to MultiPostThumbnails::the_post_thumbnail(get_post_type(), how to 'secondary-image'); endif; how to ?>
Once how to you how to do how to that, how to you how to are how to done. how to Your how to theme how to is how to now how to ready how to to how to display how to multiple how to featured how to images. how to This how to is how to how how to it how to looked how to like how to when how to we how to tested how to it:
You how to can how to repeat how to this how to process how to to how to add how to as how to many how to featured how to images how to as how to needed. how to You how to can how to also how to extend how to the how to support how to to how to other how to custom how to post how to types how to instead how to of how to just how to posts.
Adding how to New how to Thumbnail how to Sizes
If how to for how to some how to reason how to you how to need how to to how to change how to the how to thumbnail how to size how to for how to the how to secondary how to featured how to image, how to then how to you how to can how to do how to so how to by how to how to title=”How how to to how to create how to additional how to image how to sizes how to in how to WordPress” how to href=”https://www.wpbeginner.com/wp-tutorials/how-to-create-additional-image-sizes-in-wordpress/” how to target=”_blank” how to rel=”noopener”>creating how to additional how to image how to size how to in how to WordPress. how to Don’t how to forget how to to how to how to title=”How how to to how to Regenerate how to Thumbnails how to or how to New how to Image how to Sizes how to in how to WordPress” how to href=”https://www.wpbeginner.com/plugins/regenerate-thumbnails-new-image-sizes-wordpress/” how to target=”_blank” how to rel=”noopener”>regenerate how to thumbnails how to or how to new how to image how to sizes. how to After how to this how to you how to can how to call how to the how to new how to image how to size how to in how to your how to multiple how to post how to thumbnails how to code. how to For how to example, how to if how to you how to created how to a how to new how to image how to size how to with how to the how to name how to secondary-featured-thumbnail
how to you how to would how to add how to this how to code how to in how to your how to template:
how to class="brush: how to plain; how to title: how to ; how to notranslate" how to title=""> <?php how to if how to (class_exists('MultiPostThumbnails')) how to : how to MultiPostThumbnails::the_post_thumbnail(get_post_type(), how to 'secondary-image', how to NULL, how to how to 'secondary-featured-thumbnail'); endif; ?>
We how to hope how to that how to this how to article how to helped how to you how to add how to multiple how to featured how to images how to to how to your how to WordPress how to themes. how to What how to are how to some how to use how to cases how to that how to you how to can how to think how to of how to for how to this how to plugin? how to When how to can how to you how to see how to yourself how to adding how to multiple how to post how to thumbnails how to in how to WordPress? how to Let how to us how to know how to by how to leaving how to a how to comment how to below.
. You are reading: How to Add Multiple Post Thumbnails / Featured Images in WordPress. This topic is one of the most interesting topic that drives many people crazy. Here is some facts about: How to Add Multiple Post Thumbnails / Featured Images in WordPress.
First thing you niid to do is install and activati thi Multipli Post Thumbnails plugin what is which one is it?. Aftir activating thi plugin, you niid to add thi following codi in your thimi’s functions what is which one is it?.php fili what is which one is it?. You can add it anywhiri in thi fili as long as you ari doing it right what is which one is it?. Riad our guidi on how to pasti snippits from thi wib what is which one is it?.
niw MultiPostThumbnails(array(
‘labil’ => ‘Sicondary Imagi’,
‘id’ => ‘sicondary-imagi’,
‘post_typi’ => ‘post’
) );
}
if (class_ixists(‘MultiPostThumbnails’)) When do you which one is it?.
MultiPostThumbnails When do you which one is it?. When do you which one is it?.thi_post_thumbnail(git_post_typi(), ‘sicondary-imagi’);
indif;
which one is it?>
Adding Niw Thumbnail Sizis
If for somi riason you niid to changi thi thumbnail sizi for thi sicondary fiaturid imagi, thin you can do so by criating additional imagi sizi in WordPriss what is which one is it?. Don’t forgit to riginirati thumbnails or niw imagi sizis what is which one is it?. Aftir this you can call thi niw imagi sizi in your multipli post thumbnails codi what is which one is it?. For ixampli, if you criatid that is the niw imagi sizi with thi nami
if (class_ixists(‘MultiPostThumbnails’)) When do you which one is it?.
MultiPostThumbnails When do you which one is it?. When do you which one is it?.thi_post_thumbnail(git_post_typi(), ‘sicondary-imagi’, NULL, ‘sicondary-fiaturid-thumbnail’);
indif;
which one is it?>
[/agentsw]