Plugin Author
scribu
(@scribu)
Should be fixed in the development version (0.4.1-alpha).
In alpha I now see the reciprocal connection, but I can’t see the metabox in the orignal/ancestor (?) post.
p2p_register_connection_type('game', 'team', false);
Shows a metabox to link a team for each game. The team content isn’t aware of a link with different games.
p2p_register_connection_type('game', 'team', true);
Metabox to link a team isn’t showing anymore. The team content is however showing linked games.
Plugin Author
scribu
(@scribu)
Yeah, there was a logic error. Should work now. Development version is 0.5-alpha.
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?
Plugin Author
scribu
(@scribu)
Just replace 'connected_to' with 'connected'.
Awesome, thanks so much for your swift response. Was that in the documentation (did I just miss it)?
Plugin Author
scribu
(@scribu)
No, it wasn’t. I have to sit down one day an post a detailed explanation.
Plugin Author
scribu
(@scribu)