Get post thumbnail connect relationship

Support MB Relationships Get post thumbnail connect relationshipResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27822
    ThibautThibaut
    Participant

    Hello,

    how to get the featured image of the post from this code? I changed to echo $p->post_thumbnail; but doesn't work.

    Thank you

    $pages = MB_Relationships_API::get_connected( [
    'id' => 'posts_to_pages',
    'from' => get_the_ID(),
    ] );
    foreach ( $pages as $p ) {
    echo $p->post_title;
    }

    #27832
    Long NguyenLong Nguyen
    Moderator

    Hi,

    To get the post thumbnail, you can use the function get_the_post_thumbnail().

    For example:

    foreach ( $pages as $p ) {
        echo $p->post_title;
        echo get_the_post_thumbnail( $p->ID, 'thumbnail' );
    }

    Get more accessible properties of the Post class here https://developer.wordpress.org/reference/classes/wp_post/

    #27839
    ThibautThibaut
    Participant

    ok, clear thank you

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.