WordPress   

Update ACF field value when a post is created or updated

This code snippet uses save_post WordPress hook to update ACF field value when a post is created or updated. You can also perform other action using custom functions in this hook.

//Update ACf field on post creation or updation
add_action( 'save_post', 'update_acf_field_value' );
function update_acf_field_value(){
    $fieldValue = 'Example Field Value';
    update_field('field_key_here',$fieldValue);
}
Need a helping hand in fixing your website issues?

If you are facing any problems in implementing these code snippets and tutorials, you can hire us to fix your website issues.

Hire Us