WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] Retreive title and thumbnail (2 posts)

  1. snails07
    Member
    Posted 2 years ago #

    The plugin is working great, I am just having difficulty working out how to do this:

    I have a new wp_query set up to call the music videos custom post. How can I retrieve, inside of this query, the connected directors thumbnail and title?
    So in other words, the music videos are listed with the artist name, date etc (metadata for this post type) and I need to put inside each post the name of the director and thumbnail of the director (both from the connected director post type).

    I know this is probably the simplest of questions but I can't get my head around what I need to do.

    Thanks

    http://wordpress.org/extend/plugins/posts-to-posts/

  2. Manuel Schmalstieg
    Member
    Posted 2 years ago #

    Yes, this should be pretty easy to achieve.

    As a starter, you should play with this sample code:

    https://github.com/scribu/wp-posts-to-posts/wiki/Basic-usage

    Depending on your implementation, you will have to tweak this part a little bit:

    $connected = new WP_Query( array(
      'connected_type' => 'posts_to_pages',
      'connected_items' => get_queried_object_id(),
      'nopaging' => true,
    ) );

    The most important part will be to change posts_to_pages to whatever name you gave to your relation (maybe video_to_director ?).

    You can also add other conditions, such as 'post_type' => 'vid_director', to restrict it to some custom post type.

    The second step will be to adapt the HTML markup: you will want to add <?php echo get_the_post_thumbnail(); ?> at some appropriate place.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic