| 开发者 | shakewellagency |
|---|---|
| 更新时间 | 2026年11月12日 13:20 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
shakewell_relationship_sync_pairs filter, for example in your theme's functions.php or a small must-use plugin. Each pair is two field names or field keys. The pair works in both directions. A field that shares its name with the field on the other post type is paired with itself:
add_filter( 'shakewell_relationship_sync_pairs', function () { return array( // Same field name in both field groups. array( 'book_author_relationship', 'book_author_relationship' ), // Different names, matched by field key. array( 'field_64a1b2c3d4e5f', 'field_64a1b2c3d4e60' ), ); } );
Field keys are shown in the field group editor when you turn on "Field keys" in the screen options.
Repair after an import
Imports and direct database edits skip ACF, so back-links can be missing. With WP-CLI:
wp shakewell-relationship-sync repair --dry-run wp shakewell-relationship-sync repair
The command walks every post that stores a paired field, in batches, and adds the missing back-links. It never removes anything and is safe to run again. It reports posts and links checked, back-links added, links left alone because the other side was full, and links that point at deleted posts.
External services
None. The plugin makes no outside requests and collects no data.
/wp-content/plugins/, or install it with Composer, and activate it.No. The free ACF plugin is enough.
No. Values are written the way ACF writes them: an array of ids as text for multiple fields, one id as text (or an empty string) for a single post object, plus the usual field reference row.
Nothing extra. The plugin writes the other post directly, without triggering ACF again, so there is no loop and saving twice changes nothing.
The other post has no paired field (check the field group location rules), or its side is single-value or at its maximum and already holds a different post.
Yes. Anyone who can save the first post can link it, and the back-link is written without checking their rights on the other post. Do not use this plugin where that is not acceptable.
Please do not open a public issue. Follow SECURITY.md in the plugin's repository.
Post 2 Post for ACF pairs fields that share a name across field groups. Add one pair per shared name with the filter, using the same field name on both sides. Stored data is already in the right format. The plugin stays silent while Post 2 Post for ACF is active, so you can install both, then deactivate and delete Post 2 Post for ACF. Run wp shakewell-relationship-sync repair --dry-run afterwards to confirm nothing is missing. The Post 2 Post tuning filters (acf/post2post/...) have no equivalent.