As promised, this version comes with a much sexier metabox for managing connections:

Now you can:

  • Go to the connected post editing screen in one click.
  • See recent posts using the Recent button.
  • OMG! pagination.

It comes with an enhanced API to boot:

Connection information

Storing arbitrary data related to a particular connection has been possible since version 0.4, but being able to edit that data through the UI was far from easy.

So, this release brings a simple way to do that, with a new argument called ‘fields’:

p2p_register_connection_type( array(
	'from' => 'actor',
	'to' => 'movie',

	'fields' => array(
		'role' => 'Role',
		'role_type' => 'Role Type'
	),
	'context' => 'advanced'
) );

Here we just defined a connection type between actors and movies, with each connection having two additional fields: ‘role’ – the role of the actor in that particular movie and ‘role type’.

Duplicates

If you want to enable more than one connection between the same two posts, set 'prevent_duplicates' => false when registering the connection type:

p2p_register_connection_type( array(
	'from' => 'actor',
	'to' => 'movie',
	'fields' => array(
		'role' => 'Role',
		'role_type' => 'Role Type'
	),
	'context' => 'advanced',

	'prevent_duplicates' => false
) );

This will allow you to have actors with two or more different roles in the same movie, for example.

Distinct titles

Finally, for reciprocal connections, you can set different titles for the metabox, depending on which screen you’re on:

p2p_register_connection_type( array(
	'from' => 'actor',
	'to' => 'movie',
	'fields' => array(
		'role' => 'Role',
		'role_type' => 'Role Type'
	),
	'context' => 'advanced',
	'prevent_duplicates' => false,
	'reciprocal' => true,

	'title' => array(
		'from' => 'Played In',
		'to' => 'Cast'
	)
) );

With all those settings in place, you get something like this:

Acknowledgements

Special thanks to ciobi for helping with the UI awesomeness.

Thanks to Alexey Egorov for the icons.