Modify my code – which takes the first sentence of the post and use it as a h2 tag – to work outside the loop

To get post info outside the regular loop, you can use WP Query
Reference

In your example you can try something like;

$firstsentance = new WP_Query();
$firstsentance->query('posts_per_page=-1');  // add additional  query parameters as needed, this will query all posts
$old_content = the_content()';

//do your php stuff here

endwhile;