Skip to content

Instantly share code, notes, and snippets.

View fanfarian's full-sized avatar

Stefan Reichert fanfarian

View GitHub Profile
@solepixel
solepixel / acf-sync-fields.php
Created December 30, 2015 10:20
Sync 2 relationship CPT fields in ACF that are connected. Example: Actors (Relationship Field) in a Movie (CPT), and Movies (Relationship field) an Actor (CPT) has been in.
<?php
function acf_sync_field( $sync_field, $value, $post_id, $field ){
// vars
$source_field = $field['name'];
$source_global_name = 'is_updating_' . $source_field;
$sync_global_name = 'is_updating_' . $sync_field;
// get this value early before anything is updated