• Resolved Zhen

    (@milohuang)


    Hello all,

    I want to have a custom post type “series” be displayed both in Post and Page. Here is my original code.

    function my_connection_types() {
        if ( !function_exists( 'p2p_register_connection_type' ) )
            return;
    
        global $my_connection_type;
    
        $my_connection_type = p2p_register_connection_type( array(
            'from' => 'post',
            'to' => 'series'
        ) );
    }
    add_action( 'init', 'my_connection_types', 100 );

    The code provided on the Wiki (above one) can only create one connection “series and post”, how can I make it work with Page too? I tried the below and it does work for pages. The connection was established but I cannot use the code on the Wiki to display the “series” on post this time (while page works fine). Any help is greatly appreciated!

    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' => 'post',
            'to' => 'series'
        ) );
        $my_connection_type = p2p_register_connection_type( array(
            'from' => 'page',
            'to' => 'series'
        ) );
    }
    add_action( 'init', 'my_connection_types', 100 );

    https://www.ads-software.com/extend/plugins/posts-to-posts/

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

    (@scribu)

    Using version 0.9.1, you can do this:

    $my_connection_type = p2p_register_connection_type( array(
      'from' => array( 'post', 'page' ),
      'to' => 'series'
    ) );
    Thread Starter Zhen

    (@milohuang)

    Just updated to 0.9.1 and it works like a charm!! Thank you scribu for this great plugin!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Posts 2 Posts] Multiply Connections’ is closed to new replies.