Support

Account

Home Forums Front-end Issues Update post without changing its title Reply To: Update post without changing its title

  • Hi @mastafu

    I think you could just do a check for the title value in your save_post hook and ignore the changes if it’s empty.

    
    add_action( 'acf/save_post', 'my_update_existing_post_data', 10 ); 
    function my_update_existing_post_data( $post_id ) {
    	
    	if(!isset($_POST['acf']['field_5464a2a2d9a50']) || $_POST['acf']['field_5464a2a2d9a50'] == '')
    		return;
    		
    	
    	// Update existing post
    	$post = array(
    		'ID'           => $post_id,
    		'post_status'  => 'publish',
    		'post_title'   => wp_strip_all_tags($_POST['acf']['field_5464a2a2d9a50']), // Post Title ACF field key
    	);
    
    	// Update the post
    	$post_id = wp_update_post( $post );
    }
    
    

    Let me know how that works!