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:
scene2acteur
movie2sceneAn 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 :
movie1
scene1
scene2movie2
scene1movies 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>'; the_title(); echo ' --- films ---'; foreach ( $post->movie as $post ) { setup_postdata( $post ); the_title(); } } wp_reset_postdata(); }
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
- The topic ‘each_connectd with 3 relationship’ is closed to new replies.