Skip to content
This repository

Efficient many-to-many connections between posts, pages, custom post types, users.

remove phpunit as a dev dependency

Travis has phpunit pre-installed the tests should work fine with most versions.
latest commit bbc8f745be
Cristi Burcă authored
Octocat-spinner-32 admin Merge branch 'composer' into master. April 16, 2014
Octocat-spinner-32 bin Merge branch 'composer' into master. April 16, 2014
Octocat-spinner-32 core don't remove query vars from original query April 08, 2014
Octocat-spinner-32 diagrams introduce P2P_List_Renderer class April 10, 2013
Octocat-spinner-32 lang Updated language files, Swedish - sv_SE April 10, 2014
Octocat-spinner-32 tests update test bootstrap December 26, 2013
Octocat-spinner-32 .gitattributes ensure CRLF are always normalized to LF in the git database June 26, 2013
Octocat-spinner-32 .gitignore Merge branch 'composer' into master. April 16, 2014
Octocat-spinner-32 .gitmodules convert Mustache from submodule to Composer dependency June 05, 2013
Octocat-spinner-32 .svnignore run composer when building June 11, 2013
Octocat-spinner-32 .travis.yml Merge branch 'composer' into master. April 16, 2014
Octocat-spinner-32 remove phpunit as a dev dependency April 16, 2014
Octocat-spinner-32 complete changelog and bump to 1.6.3 April 02, 2014
Octocat-spinner-32 command.php cli: compose_args() isn't available anymore January 14, 2013
Octocat-spinner-32 composer.json remove phpunit as a dev dependency April 16, 2014
Octocat-spinner-32 composer.lock remove phpunit as a dev dependency April 16, 2014
Octocat-spinner-32 debug-utils.php use 'p2p_registered_connection_type' for registering missing post types September 27, 2012
Octocat-spinner-32 debug.php debug: show admin dropdown with changed title November 05, 2013
Octocat-spinner-32 phpunit.xml replace underscores with dashes in testcase file names February 07, 2013
Octocat-spinner-32 posts-to-posts.php Merge branch 'composer' into master. April 16, 2014

Posts 2 Posts

Contributors: scribu, ciobi
Tags: connections, custom post types, relationships, many-to-many, users
Requires at least: 3.5
Tested up to: 3.9
Stable tag: 1.6.3
License: GPLv2 or later
License URI:

Efficient many-to-many connections between posts, pages, custom post types, users.


This plugin allows you to create many-to-many relationships between posts of any type: post, page, custom etc. A few example use cases:

  • manually curated lists of related posts
  • post series
  • products connected to retailers
  • etc.

Additionally, you can create many-to-many relationships between posts and users. So, you could also implement:

  • favorite posts of users
  • multiple authors per post
  • etc.

Support & Maintenance

I, scribu, will not be offering support (either free or paid) for this plugin anymore.

If you want to help maintain the plugin, fork it on github and open pull requests.

Links: Documentation | Plugin News | Author's Site


See Installing Plugins.

After activating it, refer to the Basic usage tutorial.

Additional info can be found on the wiki.

Frequently Asked Questions

The waiting icon keeps spinning forever.

Check for JavaScript errors. If it's an AJAX request, check its output.


  1. Basic connection metabox
  2. Advanced connection metabox
  3. Admin column
  4. Widget
  5. Connection Types screen



  • added Serbian translation. props Borisa Djuraskovic
  • fixed spinner in admin box. props yamablam
  • fixed JavaScript error related to Backbone. props ericandrewlewis
  • made 'p2p_connected_title' filter work for users too. props MZAWeb
  • added support for 'dropdown_title' labels. props GaryJones
  • made get_related() consider all connected items


  • fixed URL query handling. props ntns
  • store WP_Error instance instead of calling trigger_error(). props MZAWeb
  • fixed warning when used with Multilingual Press. props dimadin
  • introduced p2p_connected_title filter. props petitphp


  • fixed user column handling. props versusbassz
  • fixed PHP strict standards warnings. props meloniq
  • added Estonian translation. props RistoNiinemets
  • added Finnish translation. props danielck


  • introduced p2p_candidate_title filter
  • introduced JavaScript API
  • added Japanese translation
  • various refactorings


  • fixed get_prev() and get_next()
  • introduced get_adjacent_items()
  • fixed admin column titles
  • made admin column titles show up before the post date. props luk3thomas
  • added 'help' key to 'from_labels' and 'to_labels' arrays. props tareq1988


  • fix fatal error on activation. props benmay


  • added admin dropdowns
  • fixed SQL error related to user connections
  • fixed 'labels' handling and added 'column_title' subkey
  • refactor metabox JavaScript using Backbone.js
  • lazy-load connection candidates, for faster page loads
  • lazy-load PHP classes using spl_register_autoload()


  • various bug fixes
  • added 'inline' mode for shortcodes
  • replaced 'trash' icon with 'minus' icon
  • pass direction to 'default_cb'


  • fixed each_connected() returning wrapped objects
  • fixed issue with user queries and get_current_screen()
  • fixed "Delete all connections" button
  • fixed bugs with reciprocal and non-reciprocal indeterminate connection types
  • added Dutch translation


  • fixed errors in admin box
  • fixed each_connected()


  • added 'p2p_init' hook
  • replaced 'View All' button with '+ Create connections' toggle
  • improved usability of connection candidate UI
  • fixed issues related to auto-drafts
  • show columns on the admin user list screen
  • more info


  • sanitize connection fields values on save, preventing security exploits
  • improved connection field default value handling
  • added 'default_cb' as an optional key when defining connection fields
  • fixed parameter order for 'p2p_admin_box_show' filter
  • pass the current post ID to the 'p2p_new_post_args' filter


  • allow passing entire objects to get_connected(), connect() etc.
  • made get_related() work with posts-to-users connections
  • made each_connected() work with simple array of posts
  • introduced [p2p_connected] and [p2p_related] shortcodes
  • allow 'default' parameter in 'fields' array
  • more info


  • added Tools -> Connection Types admin screen
  • fixed migration script
  • made p2p_get_connections() accept arrays of ids
  • added 'separator' parameter to p2p_list_posts()
  • made P2P_Directed_Type->connect() return WP_Error instances instead of just false
  • when a user is deleted, delete all the associated connections
  • fixed conflict with bbPress Topics for Posts plugin
  • more info


  • convert "View All" tab into button
  • refresh candidate list after deleting a connection
  • fix cardinality check
  • introduce 'p2p_connection_type_args' filter
  • make 'connected_type' accept an array of connection type names
  • inadvertently remove support for queries without 'connected_type' parameter


  • added P2P_Connection_Type->replace() method
  • added 'self_connections' flag to p2p_register_connection_type()
  • made P2P_Connection_Type->each_connected() work for posts-to-users connections
  • made admin list table columns work for posts-to-users connections
  • fixed 'from_labels' and 'to_labels' parameters
  • fixed search being limited only to post titles


  • show attachment thumbnail instead of title
  • merged 'from_object' into 'from' and 'to_object' into 'to'
  • made posts-to-users queries respect 'to_query_vars' args
  • added $prop_name parameter to P2P_Type::each_connected()
  • fixed connection field name conflict


  • fixed regression related to posts-to-users direction
  • fixed admin columns overwriting each other
  • fixed incorrect direction in admin column links
  • added notices when connection type is not properly defined


  • fixed fields not being saved for posts-to-users connections
  • fixed missing "New Post" tab in admin box
  • fixed notice when deleting post


  • fixed faulty scbFramework loading
  • simplified syntax for defining posts-to-users connection types


  • add p2p_type column to the wp_p2p table
  • new low-level api: p2p_create_connection(), p2p_get_connections(), p2p_delete_connections(), p2p_connection_exists()
  • support posts-to-users and users-to-posts connection types in the admin
  • add 'from_labels' and 'to_labels' args to p2p_register_connection_type()
  • more info


  • don't show metabox at all if user doesn't have the required capability
  • fix checkbox handling when there are no other input fields
  • improve metabox styling
  • rename 'show_ui' to 'admin_box'
  • add 'admin_column' parameter


  • widget can now list related posts
  • add P2P_Connection_Type::get_related() method
  • add 'can_create_post' arg to p2p_register_connection_type()
  • two-box mode for 'reciprocal' => false
  • more options for 'show_ui'
  • allow checkboxes, radio buttons and textareas as connection fields
  • allow drag & drop ordering in both directions
  • added get_previous(), get_next() and get_adjacent() methods to P2P_Connection_Type
  • more info


  • add '{from|to}_query_vars' args to p2p_register_connection_type()
  • add 'cardinality' arg to p2p_register_connection_type()
  • add 'id' arg and p2p_type() function
  • introduce p2p_split_posts()
  • remove p2p_connect(), p2p_disconnect() and p2p_get_connected()
  • more info


  • fix incorrect storage when creating a connection from the other end
  • respect 'reciprocal' => false when 'from' == 'to'
  • pass pagination numbers through number_format_i18n()


  • fix bug with each_connected()
  • add widget
  • allow 'from' and 'to' to be arrays again
  • improve RTL support


  • introduce dropdown connection fields
  • introduce 'sortable' arg to p2p_register_connection_type()
  • introduce 'data' arg to p2p_register_connection_type()
  • replace 'box' arg with hooks
  • replace p2p_each_connected() with P2P_Post_Type->each_connected()
  • allow using 'connected_meta' and 'connected_orderby' together
  • fix some translations
  • more info


  • added ability to create draft posts from the connection box. props Oren Kolker
  • show post status in the connection box. props Michael Fields
  • reduced number of queries by caching connection information
  • revamped p2p_each_connected()
  • introduced p2p_list_posts()
  • introduced 'connected_orderby', 'connected_order' and 'connected_order_num' query vars
  • more info


  • improved UI. props Alex Ciobica
  • added 'fields', 'context' and 'prevent_duplicates' args to p2p_register_connection_type()
  • more info


  • added p2p_each_connected()
  • fixed p2p_is_connected()
  • made p2p_get_connected() return p2p_ids even with $direction = 'any'
  • made compatible with Proper Network Activation
  • more info


  • fixed fatal error on Menus screen


  • added 'connected_meta' var to WP_Query
  • attach p2p_id to each post found via WP_Query
  • 'connected_to' => 'any' etc.
  • $data parameter can also be a meta_query
  • metabox bugfixes
  • fixed l10n loading
  • more info


  • introduced 'connected_from', 'connected_to', 'connected' vars to WP_Query
  • replaced $reciprocal with $data as the third argument
  • p2p_register_connection_type() accepts an associative array as arguments
  • removed p2p_list_connected()
  • added p2p_delete_connection()
  • more info


  • store connections using a taxonomy instead of postmeta
  • more info


  • UI that supports multiple related posts. props Patrik Bón
  • added p2p_list_connected() template tag
  • more info


Something went wrong with that request. Please try again.