Title: ACF Post-2-Post
Author: John Huebner
Published: <strong>January 2, 2017</strong>
Last modified: July 9, 2025

---

Search plugins

![](https://s.w.org/plugins/geopattern-icon/post-2-post-for-acf.svg)

# ACF Post-2-Post

 By [John Huebner](https://profiles.wordpress.org/hube2/)

[Download](https://downloads.wordpress.org/plugin/post-2-post-for-acf.1.7.0.zip)

 * [Details](https://twd.wordpress.org/plugins/post-2-post-for-acf/#description)
 * [Reviews](https://twd.wordpress.org/plugins/post-2-post-for-acf/#reviews)
 *  [Installation](https://twd.wordpress.org/plugins/post-2-post-for-acf/#installation)
 * [Development](https://twd.wordpress.org/plugins/post-2-post-for-acf/#developers)

 [Support](https://wordpress.org/support/plugin/post-2-post-for-acf/)

## Description

**_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 ACF >=5 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](https://wordpress.org/plugins/post-2-post-for-acf/)

### Github Repository

This plugin is also on GitHub
 [https://github.com/Hube2/acf-post2post](https://github.com/Hube2/acf-post2post)

### 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
        }
    }
    ```

## Installation

Install like any other plugin

## FAQ

Nothing yet

## Reviews

![](https://secure.gravatar.com/avatar/58471ff321d8732d057f537bef9f70011e9ef8185a543d23c8c0116dd6fd5144?
s=60&d=retro&r=g)

### 󠀁[Works perfectly.](https://wordpress.org/support/topic/works-perfectly-2648/)󠁿

 [style96](https://profiles.wordpress.org/style96/) July 11, 2023

works perfectly, I checked 6.2.2 wordpress version. 8.1.9 php version.

![](https://secure.gravatar.com/avatar/2d8861120a5e9117f964b256ce8539af85ece08559d68a5266188a17bd0dfac9?
s=60&d=retro&r=g)

### 󠀁[Compability](https://wordpress.org/support/topic/compability-5/)󠁿

 [galatanuadrian27](https://profiles.wordpress.org/galatanuadrian27/) May 1, 2023
1 reply

Awesome plugin! It is compatible with ACF 6+ ? Thanks!

![](https://secure.gravatar.com/avatar/80f1f9c900490ca54c563bda994eebff9ddbffd79c83ba7597d693b889ed448c?
s=60&d=retro&r=g)

### 󠀁[Perfect](https://wordpress.org/support/topic/perfect-9651/)󠁿

 [Nikodemsky](https://profiles.wordpress.org/nikodemsky/) December 14, 2022

Does exactly what it describes – simple and without hiccups, love it.

![](https://secure.gravatar.com/avatar/8c0ced2ad5a0c50ec3a0903b1d1946b4309a9b5e4ed01ff7f8d40bc710f49e3e?
s=60&d=retro&r=g)

### 󠀁[Save me lots of time.](https://wordpress.org/support/topic/save-me-lots-of-time-2/)󠁿

 [nick6352683](https://profiles.wordpress.org/nick6352683/) October 17, 2022

This plugin saves me a lot of time to manually code each relationship for each project
that needs it. Works like a charm.

![](https://secure.gravatar.com/avatar/921fe7adaafd2f2b0bf79931d9b68bc8eb5730e32c4ac7978b5fc039795f1805?
s=60&d=retro&r=g)

### 󠀁[Fantastic](https://wordpress.org/support/topic/fantastic-3001/)󠁿

 [conradish](https://profiles.wordpress.org/conradish/) April 2, 2022

This is the second time I’ve needed to use this plugin in a year. Works perfectly.
Thanks for creating and maintaining it!

![](https://secure.gravatar.com/avatar/da78e0f125efd8c27e2c36615348a954be82b9d8dedcaac48db8799586d98246?
s=60&d=retro&r=g)

### 󠀁[Amazing Plugin – Thank You](https://wordpress.org/support/topic/amazing-plugin-thank-you-14/)󠁿

 [Hossein](https://profiles.wordpress.org/hosseinkh/) November 6, 2021

Thank you very much!

 [ Read all 39 reviews ](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/)

## Contributors & Developers

“ACF Post-2-Post” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ John Huebner ](https://profiles.wordpress.org/hube2/)

[Translate “ACF Post-2-Post” into your language.](https://translate.wordpress.org/projects/wp-plugins/post-2-post-for-acf)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/post-2-post-for-acf/),
check out the [SVN repository](https://plugins.svn.wordpress.org/post-2-post-for-acf/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/post-2-post-for-acf/)
by [RSS](https://plugins.trac.wordpress.org/log/post-2-post-for-acf/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.7.0

 * Added filter to allow disabling all fields so that specific fields can be enabled

#### 1.6.0

 * Added filter to allow specifying append or prepend new relationship when not 
   overwriting

#### 1.5.2

 * Corrected PHP Notice: Trying to access array offset on value of type bool lines
   99 & 130

#### 1.5.1

 * Removed Github Updater Support

#### 1.5.0

 * Added filter to allow specifying to append or prepend new relationship (can supercede
   overwrite setting)

#### 1.4.1

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

#### 1.4.0

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

#### 1.3.2

 * removed donation nag

#### 1.3.1

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

#### 1.3.0

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

#### 1.2.8

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

#### 1.2.7

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

#### 1.2.6

 * 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}"`

#### 1.2.5

 * plugin disabled if ACF5 not installed
 * plugin deactivated if ACF5 not installed

#### 1.2.4

 * removed github updater support

#### 1.2.3

 * initial release to WordPress.org

## Meta

 *  Version **1.7.0**
 *  Last updated **9 months ago**
 *  Active installations **3,000+**
 *  WordPress version ** 4.0 or higher **
 *  Tested up to **6.9.4**
 *  Language
 * [English (US)](https://wordpress.org/plugins/post-2-post-for-acf/)
 * Tag
 * [acf](https://twd.wordpress.org/plugins/tags/acf/)
 *  [Advanced View](https://twd.wordpress.org/plugins/post-2-post-for-acf/advanced/)

## Ratings

 5 out of 5 stars.

 *  [  38 5-star reviews     ](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/?filter=5)
 *  [  1 4-star review     ](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/post-2-post-for-acf/reviews/)

## Contributors

 *   [ John Huebner ](https://profiles.wordpress.org/hube2/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/post-2-post-for-acf/)