Using a taxonomy to store post-to-post connections was an interesting exercise. It worked, but when it came time to extend it, it felled flat on its face.
That’s why connections are now stored in a custom table, with an additional meta table for adding arbitrary information per connection.
It is now possible to connect the same two posts twice, but with different metadata, something that would be needed in Justin Tadlock’s movies scenario, for example.
The procedure for migrating old connections is the same as in the previous version: go to /wp-admin/?migrate_p2p and you’re done. (Make sure you have a recent database backup before you do this.)
When searching for posts to connect, it will search only by post title and not by content, as in previous versions.
Reciprocal connections are now stored only once.
Speaking of reciprocal connections, most function in the API accepted a the third parameter, which used to be $reciprocal = false
. It has been replaced with $data = array(). More info can be found in the file api.php.
Unless you’re doing advanced stuff, you shouldn’t need to touch the API, though. You can just use WP_Query or get_posts():
Get posts connected from a particular post: $post_id -> $posts
$connected = get_posts( array(
'suppress_filters' => false,
'post_type' => 'book',
'connected_from' => $post_id,
) );
Get posts connected to a particular post: $post_id <- $posts
$connected = get_posts( array(
'suppress_filters' => false,
'post_type' => 'book',
'connected_to' => $post_id,
) );
Get connected posts, regardless of direction: $post_id <- $posts OR $post_id -> $posts
$connected = get_posts( array(
'suppress_filters' => false,
'post_type' => 'book',
'connected' => $post_id,
) );