• Resolved Super Interactive

    (@superinteractive)


    I have a website with a set of post types, and I want to be able to create relations between posts from all post types. So a post from any type can be connected to any other post from any other type. What would be the most efficient way to do this?

    Right now I use something like this to dynamically create all possible conections:

    https://gist.github.com/superinteractive/6933727

    This loops through an array with post types but iterates the start of the array with every step to avoid double connections (since they are reciprocal).

    This however seems to create extremely expensive queries when retrieving connection on the front-end. Theoretically it shouldn’t take that much horse powers to retrieve the connections, so I’m thinking there must be a more efficient way.

    Hope you have some suggestions!

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m trying to figure this out too since i have multiple custom post types and i want to relate anything from posts and pages to those custom post types and vice versa.

    If i figure it out, i will let you know. If you figure this out, i hope you post back here.

    Thread Starter Super Interactive

    (@superinteractive)

    Ok, no idea why I haven’t thought of this before, but turns out it’s quite simple:

    $post_types = array( 'post', 'custom-post-type-1', 'custom-post-type-2' );
    
    p2p_register_connection_type( array(
    	'name' => 'multi_connections',
    	'from' => $post_types,
    	'to' => $post_types,
    	'reciprocal' => true
    ) );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cross link several post types’ is closed to new replies.