• Resolved snails07

    (@snails07)


    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/

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Posts 2 Posts] Retreive title and thumbnail’ is closed to new replies.