By default, most WordPress themes come with built-in support for featured images which makes adding post thumbnails really simple. But when you work on custom projects, you might need to add a second featured image to a poste, page and also in custom post types.

In this article we will show you how to add multiple post thumbnails / featured images in WordPress.

In the first place you need to install and activate Β Multiple Post Thumbnails plugin. After activating the plugin, add the following code into your theme’s functions.php file.

 

After you added the code, you can now add a secondary featured image to your post or page or custom post type. You shloud see new meta box after the featured image box.

 

 

Once you set secondary image to your post, now it’s time to show you how to display secondary image. This could be in your single.php (for single posts), index.php (when you loop the posts), etc. you have juste to insert the below mentioned code.

 

 

you can also pass a parameter along with arguments including a class or title. For this, just include the below mentioned code instead of code above:

 

 

Although this is an optional step, it is better to implement the same to ensure that the newly added featured image gets resized automatically. Here, just open your functions.php file and add the below code to it:

 

I hope that this article helped you to add multiple featured images to your WordPress themes.

 


No Comments

Leave a Reply

your email address will not be published. required fields are marked *

*
*