I am using the multi post thumbnails plugin. I have a custom post type "artist" who has a logo. In the loop I want to echo out the following:

$logo = MultiPostThumbnails::get_post_thumbnail_id('artist', 'Logo', $post->ID);
echo $logo;

Nothing gets returned - I used a var_dump on $logo to check, it is just an empty string. $post->ID returns the right id, and the parameters artist and Logo should be correct, too.

What am I doing wrong here?

  • Quick suggestion: Have you checked cases? Should 'Logo' possibly be lower-case? – Johannes Pille Nov 22 '12 at 23:04

First check if the post has a thumbnail:

$has_thumbnail = MultiPostThumbnails::has_post_thumbnail( 'artist', 'Logo', $post->ID );

If the post has no thumbnail, maybe you don't have attached a thumbnail to the post.

| improve this answer | |
  • Thanks for your reply - var_dumping $has_thumbnail leaves me with an empty string as well. Is there something I am forgetting? – weltschmerz Nov 22 '12 at 21:57
  • It seems so. Please check if the plugin is correctly installed, read the plugin documentation and check if all needed steps was correctly done, turn on debugging (WP_DEBUG = TRUE) and look out for errors, etc. There are thousands of possible errors. – Ralf912 Nov 23 '12 at 11:59

I have found the solution:

$logo = MultiPostThumbnails::get_the_post_thumbnail('artist', 'artist-logo', NULL, 'artist-logo');

It was clearly a matter of the right parameters. The second one has to refer to the thumbnail description in my functions.php, the third one has to be NULL, and the last one needs to be the same as the second one.

Thanks for your help!

| improve this answer | |

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.