Multiple Post Thumbnails
[resolved] Two Errors in get_the_post_thumbnail function (2 posts)

  1. helgatheviking
    Posted 4 years ago #

    two issues with the parameters in the get_the_post_thumbnail function

    get_the_post_thumbnail($post_type, $thumb_id, $post_id = NULL, $size = 'post-thumbnail', $attr = '' , $link_to_original = false)

    first: the default size is 'post-thumbnail'. i don't believe there IS a size called 'post-thumbnail'. the smallest, thumbnail size is simply called 'thumbnail'

    second: the $post_id is null by default. in the example on the plugin page you pass this parameter as NULL, I suppose presumably b/c the $post_id will be automatically set to the current post by default. except this doesn't happen.

    global $id;
    $post_id = (NULL === $post_id) ? $id : $post_id;

    this $id variable has no value, so if you don't pass get_the_ID() in as the post ID parameter, you will not get an image.

    seems like this should be:

    global $post;
    $post_id = (NULL === $post_id) ? $post->ID : $post_id;


  2. Chris Scott
    Plugin Author

    Posted 4 years ago #

    Thanks for the feedback.

    The default size is the same as WP's the_post_thumbnail() uses.

    For the $post_id, I could've sworn I lifted that from get_the_post_thumbnail() but it looks like I didn't. This is fixed in version 1.0. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Multiple Post Thumbnails
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic