Added code for creating and updating posts