Duplicate connections and cardinality

Gary Jones edited this page Nov 26, 2013 · 7 revisions

Duplicate connections

By default, after you connect post A to post B, post B disappears from the list of candidate posts.

If you want to be able to create multiple connections between the same posts, just set 'duplicate_connections' to true:

p2p_register_connection_type( array(
  'duplicate_connections' => true
) );


The default cardinality is many-to-many. This means that a post can connect to many other pages and a page can connect to many other posts.

You can change this, however:

p2p_register_connection_type( array(
  'from' => 'post',
  'to' => 'page',
  'cardinality' => 'one-to-many'
) );

Now, a post can still connect to many other pages, but a page can connect to only one post.

This can be reversed also using many-to-one.