Skip to content

p2p_register_connection_type

scribu edited this page Mar 5, 2013 · 1 revision

p2p_register_connection_type() is the function you use to - you guessed it - register a connection type. See Basic usage for a quick example.

It accepts a single parameter, which should be an associative array. Here are all the keys that are recognized:

  • 'name' - string A unique identifier for this connection type.
  • 'from' - string|array The first end of the connection: post type name or 'user'
  • 'from_query_vars' - array Additional query vars to pass to WP_Query. Default: none.
  • 'to' - string|array The second end of the connection: post type name or 'user'
  • 'to_query_vars' - array Additional query vars to pass to WP_Query. Default: none.
  • 'fields' - array( key => Title ) Metadata fields editable by the user. Default: none.
  • 'cardinality' - string How many connection can each post have: 'one-to-many', 'many-to-one' or 'many-to-many'. Default: 'many-to-many'
  • 'duplicate_connections' - bool Whether to allow more than one connection between the same two posts. Default: false.
  • 'self_connections' - bool Whether to allow a post/user to connect to itself. Default: false.
  • 'sortable' - bool|string Whether to allow connections to be ordered via drag-and-drop. Can be 'from', 'to', 'any' or false. Default: false.
  • 'title' - string|array The box's title. Default: 'Connected {$post_type}s'
  • 'from_labels' - array Additional labels for the admin box (optional)
  • 'to_labels' - array Additional labels for the admin box (optional)
  • 'reciprocal' - bool For indeterminate connections: True means all connections are displayed in a single box. False means 'from' connections are shown in one box and 'to' connections are shown in another box. Default: false.
  • 'admin_box' - bool|string|array Whether and where to show the admin connections box. Default: 'any'. See Admin box display
  • 'can_create_post' - bool Whether to allow post creation via the connection box. Default: true.
  • 'admin_column' - bool|string|array Whether to show connection columns on post/user list table. Default: false
  • 'admin_dropdown' - bool|string|array Whether to show connection dropdown on post/user list table. Default: false. See Admin dropdown display

Clone this wiki locally