Support

Account

Home Forums General Issues Save ACF-Text as WP-Default-Post-Text

Solving

Save ACF-Text as WP-Default-Post-Text

  • Hello everyone

    I like the ACF and create better Post-Section for the User.
    But like every default WP-Post there we have the default WP-Post-Photo and the WP-Post-Text.
    I found out, how to connect the ACF-Photo to the default Post-Photo with when use _thumbnail_id for the name. But how can I connect the ACF-Text to the default Post-Text?

    I could not find any documentation about that here so far.

  • Do you mean post_content?

    
    add_action('acf/save_post', 'your_function_name_here');
    function your_function_name_here($post_id) {
      $post = get_post($post_id);
      $content = get_field('your_field_name_here');
      if ($content) {
        $post->post_content = $content;
        // remove this filter to prevent infinite loop
        remove_filer('acf/save_post', 'your_function_name_here');
        wp_update_post($post);
      }
    }
    
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Save ACF-Text as WP-Default-Post-Text’ is closed to new replies.