WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Matt Barrett (corradomatt)
    Member
    Posted 1 year 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?

    http://wordpress.org/extend/plugins/types/

  2. Srdjan
    Member
    Plugin Author

    Posted 1 year 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)
    Member
    Posted 1 year 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

Tags

No tags yet.