Support

Account

Home Forums General Issues Can related posts inherit ACF field values? Reply To: Can related posts inherit ACF field values?

  • If you have the posts linked already I think you’d just need to update the field in the relationship posts when the post is saved.

    I used update_field() and ACF/save_post

    I’ve done something similar in a solution I built to update the field values of a specific post from any page on the website.

    
    function update_variant_fields($post_id) {
    
      // Get related Base Cards using the relationship field
      $base_cards = get_field('base_card_relationship_field', $post_id);
    
      if ($base_cards) {
        foreach ($base_cards as $base_card_post) {
          $power = get_field('power', $post_id);
          $cost = get_field('cost', $post_id);
    
          update_field('power', $power, $base_card_post->ID);
          update_field('cost', $cost, $base_card_post->ID);
        }
      }
    }
    add_action('acf/save_post', 'update_variant_fields'); // Update on post save
    

    I realized after I made it could have probably changed $base_card_post->ID into its own variable.

    Hope this helps!