• Resolved gillespieza

    (@gillespieza)


    Reciprocal relationships are not being created, even when set to “true”. I am using version 0.4.

    Perhaps I’m just not understanding how the plugin is meant to work, but if reciprocal = true, should I not be seeing a connection automatically filled in the Edit Post screen?

    Here is the code I have placed in my functions.php:

    /** Many to Many Post relationships (Post 2 Post plugin)
     */
    function my_connection_types() {
        if ( !function_exists('p2p_register_connection_type') )
            return;
    
        p2p_register_connection_type( 'film', 'film', true );
    }
    add_action('init', 'my_connection_types', 100);

    (Apart from that – thank you so much for this plugin! I could kiss the ground you walk on for this!)

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author scribu

    (@scribu)

    I’m looking into it.

    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.

    Thread Starter gillespieza

    (@gillespieza)

    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'.

    Thread Starter gillespieza

    (@gillespieza)

    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)

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Posts 2 Posts] Reciprocal relationship not being created’ is closed to new replies.