跳到内容

Shakewell Two-way Relationships for ACF

v0.1.1

shakewellagency · 2026年11月12日 上架

When a post is linked to another through an ACF relationship or post object field, the other post links back. Unlinking removes the link back.

正在使用
10 以下
评分
暂无
累计下载
160
最近更新
2026年11月12日
需要 WordPress 6.5+已测试到 7.1.5PHP 8.1+

Link a book to its author and the author shows the book too. Remove the link on either side and it disappears from both.

You tell the plugin which fields belong together. It then keeps both posts in step whenever Advanced Custom Fields saves one of them. It stores values exactly as ACF does, so nothing needs migrating and your REST output and templates do not change.

How it behaves:

  • Works with ACF relationship fields and post object fields, single or multiple.
  • Adds the back-link at the end of the other list, so the order of existing links is kept. Linking twice never duplicates.
  • A single-value side, or a relationship side that has reached its maximum, is left as it is. The plugin never replaces another link.
  • Ignores revisions, autosaves and non-post locations such as options pages and users.
  • Does not listen to trashing, restoring or deleting a post. Links to a trashed post stay until you change them.
  • The other post is updated whenever the editor may save the first post. There is no separate capability check on the other post.
  • It does not use ACF’s own “bidirectional” setting, so it also works with data created before that setting existed.
  • No settings screen, no database tables, no front-end output.

Requires Advanced Custom Fields, free or Pro. WordPress cannot express “free or Pro” as a plugin dependency, so the plugin checks at run time and shows an admin notice if ACF is not active.

Setup

Add the pairs with the 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.

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums