Skip to content

Duplicate connections and cardinality

scribu edited this page Nov 24, 2011 · 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 'prevent_duplicates' to false:

p2p_register_connection_type( array(
  ...
  'prevent_duplicates' => false
) );

Cardinality

The default cardinality is many-to-many. This means that post A 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 have only one page connected to it.