Easy way to automatically add code to prior posts

Like auto add custom fields to prior posts or new posts.