When I add this to my functions.php (I am using a Child theme) I get an error.
In the specific the error says syntax error, unexpected '=' ... on linke 54
On that line there is this
$post->post-title = $title;
BTW: I would like that all the posts are saved with the Value in the “title” field