Custom Fields
Re-Envisioned
Support MB Relationships Is it possible to get the thumbnail of a "relationship" post?

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 6 months ago.

  • Creator
    Topic
  • #13271
    Resolved
    Vee Jay
    Participant

    I’m trying to create relationship between posts.

    So far it works well, but was wondering if it would be possible to grab the thumbnail of a “relationship” post?

    How would I achieve this?

    Here’s the code I got working so far when it comes to my relationship:

    $connected_pub2peeps = new WP_Query( array(
                        'relationship' => array(
                            'id'   => 'pub2peeps',
                            'from' => get_the_ID(), // You can pass object ID or full object
                        ),
                        'nopaging'     => true,
                    ) );
                    if($connected_pub2peeps)
                        echo 'Connected People: ';
                    while ( $connected_pub2peeps->have_posts() ) : $connected_pub2peeps->the_post();
                        ?>
                        <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
                        <?php
                    endwhile;
                    wp_reset_postdata();

    Nevermind just realized how dumb I was.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #13290

    Anh Tran
    Keymaster

    Hi Vee Jay,

    After you call $connected_pub2peeps->the_post(), you can output the featured image using the_post_thumbnail() function.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.