Post Meta Values Automatically Deleted in WordPress?
By on March 18th, 2011

I use a lot of custom meta fields in WordPress posts for several reasons. They allow me to manipulate multiple posts without having to write code for a specific conditions.

WordPress Logo

However, of late, I came across a very annoying problem where custom meta fields were automatically deleted for some reason that was unknown to me. It was annoying me to no end because I had to manually go in and add those custom fields for the posts over and over again.

I didn’t have much time to figure out what is wrong and left in some debug code which would allow me to later on see how things were disappearing. Today, I checked those logs and found out the problem with the disappearing custom meta fields.

The problem was that, WordPress processes hooks for the edit_post, publish_post and save_post not just for editing the posts but also various other functions like while approving comments too, but the code in question always tried to find the $_POST variables and delete them if they didn’t exist. This was the mystery behind those disappearing post custom meta fields.

Solution For The Problem?

If you are not a developer, you are better off disabling those plugins and adding those fields manually using WordPress write interface. However, if you use a plugin you might lose additional functionality it provides. You could always send an email to the plugin developer asking them to make the appropriate changes.

If you are a developer, Mark Jaquith has a post which talks about avoiding such problems. You can read the post here and modify your plugin or theme to fix this issue.

Tags: , , , ,
Author: Keith Dsouza Google Profile for Keith Dsouza
I am the editor-in-chief and owner of Techie Buzz. I love coding and have contributed to several open source projects in the past. You can know more about me and my projects by visiting my Personal Website. I am also a social networking enthusiast and can be found active on twitter, you can follow Keith on twitter @keithdsouza. You can click on my name to visit my Google+ profile.

Keith Dsouza has written and can be contacted at keith@techie-buzz.com.
  • http://www.webguide4u.com Vivek Parmar

    Thanks for sharing. Now have to look into my logs too.

 
Copyright 2006-2012 Techie Buzz. All Rights Reserved. Our content may not be reproduced on other websites. Content Delivery by MaxCDN