Hi Scribu
I'm having some issues with reciprocal links and I'm not sure if its a WordPress 3.2 thing or if I've done something wrong, or perhaps I'm just not understanding something. I'm using version 0.7 with WordPress 3.2.
In my functions file, I have the following:
function my_connection_types() {
if ( !function_exists( 'p2p_register_connection_type' ) )
return;
p2p_register_connection_type( array(
'from' => 'film',
'to' => 'film',
'reciprocal' => true
) );
}
add_action( 'init', 'my_connection_types', 100 );
In my single-film.php file, I have:
$screenswith = "";
$connected = new WP_Query( array(
'post_type' => 'film',
'connected_to' => get_queried_object_id()
) );
if( $connected->have_posts() ) {
$screenswith = '<div class="screenswith arrow_list"><h6>Screens with:</h6>';
$screenswith .= '<ul>';
while( $connected->have_posts() ) : $connected->the_post();
$screenswith .= '<li><a href="'.get_permalink().'" title="'.get_the_title().'" target="_blank">'.get_the_title().'</a></li>';
endwhile;
$screenswith .= '</ul>';
$screenswith .= '</div>';
}
wp_reset_postdata();
echo $screenswith;
The reciprocal relationship is being created in the admin backend, but on the front end, only one post shows the $screenswith data - the other post is "blank". If I change the request from connected_to to connected_from, then they switch - the previously blank post now shows the connected post, and the other is then blank.
Perhaps I've just missed something in the wiki, but I thought reciprocal would create a from/to relationship in both directions on the front end as well?