Posts 2 Posts: Version 1.3
In this release, I focused on making the API more uniform; everything works for both posts-to-posts and posts-to-users connections now. This is possible because you can pass whole post and user objects, instead of just IDs.
$connected = get_users( array( 'connected_type' => 'posts_to_users', 'connected_items' => $post->ID ) );
$connected = get_users( array( 'connected_type' => 'posts_to_users', 'connected_items' => $post ) );
This small change gives P2P more information to work with, which means fewer database queries are needed.
The plugin now comes with a pair of shortcodes for conveniently listing connected items anywhere.
Say you defined a connection type called ‘posts_to_pages’. Here’s how the shortcode would look like:
If you insert that into a post, it will display a list of connected pages. If you insert it into a page, it will display a list of connected posts.
And there’s one for related posts too:
Shortcodes and widgets also have filters for modifying the HTML output.
Default field values
You can now set default values for the connection fields in the metabox, likes so:
p2p_register_connection_type( array( 'name' => 'posts_to_pages', 'from' => 'post', 'to' => 'page', 'fields' => array( 'color' => array( 'title' => 'Color', 'type' => 'checkbox', 'values' => array( 'green', 'yellow', 'blue', 'white' ), 'default' => 'blue' ), ) ) );
In total, there were 16 resolved issues in this release.comments powered by Disqus