Support » Plugins » [Plugin: Advanced Custom Field]Update the attachment's post_parent of type Image

  • Resolved ringomamama

    (@ringomamama)


    Would like to ask which is the most suitable hooks to do this?
    something like:

    function my_acf_update_value( $value, $post_id, $field  )
    {
        wp_update_attachment_metadata( $value, array('post_parent'=>$post_id) );
        return $value;
    }
    
    add_filter('acf/update_value/type=image', 'my_acf_load_field', 10, 3);

    Thanks for any helps, gratitude!

Viewing 1 replies (of 1 total)
  • always figure out the solution right after posted the question, the solution is here:

    function my_acf_update_value( $value, $post_id, $field  )
    {
    	wp_update_post(array(
            'ID' => $value,
            'post_parent' => $post_id
        )
    	);
        return $value;
    }
    
    // acf/update_value/type=image - filter for a specific field based on it's type
    add_filter('acf/update_value/type=image', 'my_acf_update_value', 10, 3);
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Advanced Custom Field]Update the attachment's post_parent of type Image’ is closed to new replies.