• Resolved Kay

    (@kayheunen)


    Dear Scribu,

    I’m having a reciprocal relationship between my custom post types: ‘diensten’ and ‘projecten’. Using the following code:

    function my_connection_types() {
        // Make sure the Posts 2 Posts plugin is active.
        if ( !function_exists( 'p2p_register_connection_type' ) )
            return;
    
        // Keep a reference to the connection type; we'll need it later
        global $my_connection_type;
    
        $my_connection_type = p2p_register_connection_type( array(
            'from' => 'diensten',
            'to' => 'projecten',
            'reciprocal' => true
    
        ) );
    }
    add_action( 'init', 'my_connection_types', 100 );

    However this seems to be alright. I’m only able to update the connection via the custom post type ‘diensten’ (the from param). Though it shows up on the custom post type ‘projecten’ edit page, I’m able to delete a current relationship, but I’m not able to create a relationship (selecting one of the ‘diensten’ posts).

    Could you help me, or tell me what I’m doing wrong?

    Thanks in advance.
    Kind regards,

    Kay Heunen

    http://wordpress.org/extend/plugins/posts-to-posts/

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

    (@scribu)

    It works ok for me.

    Could you explain what exactly happens when you try to make a connection from a ‘projecten’ post? A screenshot uploaded to imgur.com maybe?

    Thread Starter Kay

    (@kayheunen)

    This is wat I’m doing.

    1. Go to projecten overview
    2. Edit a post
    3. Click on the ‘view all’ in the connection box
    4. Than I click on the ‘+’ to add the connection
    5. I see a connection in the meta box
    6. Than I hit Update/save
    7. The connection is gone (or actually never sent to the db)

    When I check my database I only see a one way relationship i.e.
    primaryId From To
    1 489 909

    Where as when I do it the other way around (edit a post in diensten) it does this:
    primaryId From To
    1 489 909
    2 909 489

    I’ve checked with other post types, nothing there..

    This is a great little tool if you need to share a screenshot or record a short video of your actions on the screen.

    I’m not related to them, but it has proven to be very useful for debugging over time.

    Plugin Author scribu

    (@scribu)

    Ok, I was able to reproduce this.

    The problem was that the connection was stored as projecten->diensten instead of diensten->projecten.

    Should be fixed in the development version (0.9.2-alpha).

    Thread Starter Kay

    (@kayheunen)

    Dear Scribu,

    Awesome, thanks for your quick reply and fix.
    I forked .9.2-alpha and the tabs aren’t working anymore, just wanted to let you know.

    I took the stable plugin and changed your last two commits locally here, now the tabs are working. Great plugin!!

    Kind regards.

    Plugin Author scribu

    (@scribu)

    The tabs don’t work because you have to generate the JavaScript file:

    https://github.com/scribu/wp-posts-to-posts/wiki/Development-guide

    Plugin Author scribu

    (@scribu)

    I added admin/box.js to the git repo so that you don’t have to build it yourself, when you just want to test.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Posts 2 Posts] Reciprocal only working one way’ is closed to new replies.