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?

  • if you just want a different image size of the same image, you can do that a bit simpler, otherwise use @cjbj's solution. – majick Jun 6 '16 at 14:42

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');
    the_post_thumbnail(); //fallback in case somebody doesn't have the plugin installed
  • Hey, Thanks. Two things though. 1. I need it for product, not post. Will that work? 2. Where to add that second snippet you posted? – Irfan Saleem Jun 6 '16 at 14:09
  • The product is presumably a custom post type. You would have to change the line that says 'post_type' => 'post', but I don't know to what post type, because I don't know how your custom post type is defined. The second snippet would go into the template file where you want the secondary featured image to display. For instance, if you want it on single pages, open single.php and replace the_post_thumbnail in that file with the snippet. – cjbj Jun 6 '16 at 14:20
  • It is Woocommerce. So I think its name would be "product" right ? I added the plugin but the secondary area does not seem to show in Products – Irfan Saleem Jun 6 '16 at 15:06
  • Sorry, I have no experience with woocommerce, so I can't help you with that. – cjbj Jun 6 '16 at 15:07
  • 1
    yeah, or read the manual: docs.woothemes.com/document/installed-taxonomies-post-types – cjbj Jun 6 '16 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.