Different Featured Images depending on context: loop or single view

I want to keep different image on the single post type page and a different image if the post type is showing in a loop. Is there any way?

Perhaps we can use the gallery image as featured on single view but if so, how?

Topic post-thumbnails Wordpress

Category Web


The easiest way to achieve this is to use the Multiple Post Thumbnails plugin. Once you have done this, add the following snippet to your functions file:

if (class_exists('MultiPostThumbnails')) {
    new MultiPostThumbnails(array(
    'label' => __('Secondary Featured Image', 'yourtextdomain')
    'id' => 'secondary-image',
    'post_type' => 'post'
    ));
    }

This will make a box 'Secondary Featured Image' available on your edit post page. Now you will have to place it in your theme, wherever you want the secondary featured image to appear in stead of the primary:

if (class_exists('MultiPostThumbnails')) 
    MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');
else
    the_post_thumbnail(); //fallback in case somebody doesn't have the plugin installed

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.