Life is an adventure, this is the story of mine!

Custom Data disappears on Custom Post Types

With WordPress 3.0 Custom Post Types came to life and within the project I am working on we started to use them, each post needs to have a set of custom data to associate with. Basically we were adding new posts with custom data and everything was looking fine in the front end, but after a while the custom data would disappear from the blog entry without any post update being performed on the backend… strange strange voodoo. Some checks on the logs and on the database showed no errors so something else was triggering this behavior, there was no voodoo at all this was due to the “autosave” routine performed when you have the “Edit Post” page on the dashboard open.

The problem is that the autosave option does not pass by post the Custom Fields we add to the Custom Post type so when the “save post data” is called those fields are set to blank and you loose your data. Its extremely easy to avoid this by adding an extra hidden field which will work as an id for your custom data form.

About

I am a Software Engineer currently living in Lisbon, Portugal pursuing the dream of creating my own company. After working for the University of Évora, for the well known Portuguese company YDreams S.A in Lisbon and for two years for the European Space Operations Center (ESOC) in Germany, I decided it was time to experience a different adventure. This ... is that story!