Types - Custom Fields and Custom Post Types Management
[resolved] Displaying Child Post Thumbnail Featured Image (3 posts)

  1. Matt Barrett (corradomatt)
    Posted 2 years ago #

    Hi guys,

    I've search high and low for the answer to this one with no luck. I am trying to display a simple grid of child posts on the parent post's page and would like to use the default featured image feature of wordpress to display the $child_post images.

    I assumed that I could just use <?php echo $child_post->the_post_thumbnail(); ?> but it returned an error of PHP Fatal error: Call to undefined method stdClass::the_post_thumbnail()

    Should I be doing this a different way?


  2. Srdjan
    Plugin Author

    Posted 2 years ago #

    Child post is essentially clone of WP's $post.
    I think it is not instance of class you need.

    echo get_the_post_thumbnail( $child_post->ID, 'post-thumbnail', $attr = '' );

  3. Matt Barrett (corradomatt)
    Posted 2 years ago #

    That worked perfectly Srdjan! Thanks for the explaination.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.