Support » Plugin: Posts 2 Posts » each_connectd with 3 relationship

  • Hello, I discovered your plugin a few days ago and this is what I was looking for but I have a question.

    I created 2 relationships:


    An actor can play in a scene and a scene is in a movie

    When I am on the actor page, I want to display link like this :



    movies and scenes are links. This is the code I made, inspired by the example of the wiki

    $my_query = new WP_Query( array(
    	'post_type' => 'acteur'
    ) );
    p2p_type( 'scene2acteur' )->each_connected( $my_query, array(), 'scene' );
    while ( $my_query->have_posts() ) { $my_query->the_post();
    	// Another level of nesting
    	p2p_type( 'movie2scene' )->each_connected( $post->scene, array(), 'movie' );
    	foreach ( $post->scene as $post ) {
                setup_postdata( $post );
         echo '<pre>'   ;print_r($post); echo '</pre>';
    		echo ' --- films ---';
    		foreach ( $post->movie as $post ) { setup_postdata( $post );

    My first problem is that I have to find each scene before finding attached films. The scenes must be grouped by movie

    My second problem is that I don’t manage to modify the_title(); into a real link like this

    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

    thank you for your help

Viewing 2 replies - 1 through 2 (of 2 total)
  • To the second problem:


    echo'<li><a href="'.the_permalink().'">'.get_the_title().'</a></li>

    ok thank you I will this.

    For my first problem, i really don’t know how to resolve it.

    I want to organise my links by movies when I am on an actor page but actor and movies are not directly linked.
    an actor is linked to a scene only. and a scene is linked to a movie.

    So I have to get first the scene in where the actor plays to and only after this step I can get the movie.

    I could reorganise the loop to change the display but I don’t know how to group scenes under a same movie

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘each_connectd with 3 relationship’ is closed to new replies.