Refactor the if/else in edit_post.