ACF Post-2-Post


This is an add on plugin for Advanced Custom Fields (ACF) Version 5.

This plugin will not work with ACF Version 4.

This plugin will not provide any functionality if ACF5 is not installed.***

This plugin does not create a new type of field or any admin interface. This plugin when used as
explained below makes the existing ACF Relationship and Post Object fields work bi-directionaly,
automatically updating the relationship field on the other end of the relationship.

For more information see Other Notes

Github Repository

This plugin is also on GitHub

How To Use

  • Create a relationship or post object field.
  • The field must be at the top level. It cannot be a subfield of a repeater or a flexible content field.
  • The field name must be the same on all posts. In other words if you want to have different post types be related then you must add a field with the same field name on both post types.

When you add a post to a relationship or post object field and the same field name appears on the post added to the relationship then the relationship field on the related post will be updated to include a relationship to the post being edited.

If a post is removed from a relationship then the post being removed will also be updated to remove the relationship to the post being edited.

Post Object Fields

If a post object field is being used

  • If it allows multiple values then it will work the same way that relationship fields work.
  • If it does not allow multiple values and the related post already contains a value see Overwrite Settings

Overwrite Settings

If the field in a related post, whether it is a post object field that only allows 1 value or a relationship field that has a maximum number of related posts, if the field in the related post already has the maximum number of values allowed, by default, a new value will not be added. You can override this default by specifying overwrite settings.

How to add overwrite settings

add_filter('acf-post2post/overwrite-settings', 'my_overwrite_settings');
function my_overwrite_settings($settings) {
  $settings['field_name'] = array(
      'overwrite' => true,
        'type' => 'first'
  return $settings;

Each element of the $settings array is an array. The index of the array is the field that you want to specify settings for. Each field can have 2 arguments.

  • overwrite: true/false or 1/0. If set to true or 1 then new values will overwrite older values. The default value of this setting is false.
  • type: ‘first’ or ‘last’. Which of the existing values should be removed, the first one added or the last. The default value is ‘first’.

after a value is removed from the existing list the new value is added to the end of the list.

Field Exeptions

You can disable automatic bidirectional relationships for specific field keys using the filter

// field_XXXXXXXX = the field key of the field
// you want to disable bidirectional relationships for
add_filter('acf/post2post/update_relationships/key=field_XXXXXXXX', '__return_false');

After update hooks

There are two actions that can be used after a post is updated and passes a single post ID. Please make sure you see the subtle difference in these two hooks.

The first is run after each related post is updated

add_action('acf/post2post/relationship_updated', 'my_post_updated_action');
function my_post_updated_action($post_id) {
  // $post_id == the post ID that was updated
  // do something after the related post is updated

The second is run after all posts are updated and passes an array of post IDs.

add_action('acf/post2post/relationships_updated', 'my_post_updated_action');
function my_post_updated_action($posts) {
  // $posts == and array of post IDs that were updated
    // do something to all posts after update
    foreach ($posts as $post_id) {
      // do something to post


Install like any other plugin

Часто задаваемые вопросы

Nothing yet


Works perfectly with ACF Pro Version 5.8.8 - can't understand why isn't it included in ACF core. Epic!
Incredibly useful if you need to create relationships between objects of different post types.
If you're dealing with large data sets, this plugin can save massive amounts of query time and speed up your site. Like everyone else said, it's a "must have"!
Hi John, thanks alot for this extension - which covers a very important area, when dealing with theme development.
Also using Pods Frameworks, its really hard to grasp that this feature isn't built in to ACF. Taking the classic book/author relationship, you'd obviously expect, that when you add a book to an author, you can not only see that this author wrote that book, but also that this book was written by that specific author, and vice versa. This plugin fixes that. So go use it!
Посмотреть все 27 отзывов

Участники и разработчики

«ACF Post-2-Post» — проект с открытым исходным кодом. В развитие плагина внесли свой вклад следующие участники:


Перевести «ACF Post-2-Post» на ваш язык.

Заинтересованы в разработке?

Посмотрите код, проверьте SVN репозиторий, или подпишитесь на журнал разработки по RSS.

Журнал изменений


  • Corrected logic error in overwrite
  • add context to action hooks


  • added actions after updates to related posts to allow 3rd party integrations


  • removed donation nag


  • Corrected bug in 1.3.0 that prevented all fields from updating correctly


  • added filter to allow disabling bidirectional relationships on fields by field key


  • changed from plugins_loaded to after_setup_theme for checking if ACF >= 5 is installed to allow for ACF being installed in themes


  • replace php array_walk() w/array_map() to correct issue with str/int conversion of IDs


  • corrected serialization of post IDs as strings instead of integers to allow correct ACF meta_key value searching of serialized ID values useing LIKE "{ID}"


  • plugin disabled if ACF5 not installed
  • plugin deactivated if ACF5 not installed


  • removed github updater support


  • initial release to