Skip to main content
added 436 characters in body
Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

I'd say there is barely enough information in the question to speculate on an answer but it sounds like to me that...

If your data is saved in individual key/value pairs then delete_post_meta will do it. You would pullpass the function a post ID and a key name: (I assume)delete_post_meta(1,'keyname');. It will delete the whole key/value pair.

If you have multiple bits of information saved as a serialized array/object then delete_post_meta will not work. You will need to pull the data for the key you want with get_post_meta, alter the array/object in PHP to remove the key/value you want to delete, and then save the altered data with update_post_meta.

http://codex.wordpress.org/Function_Reference/get_post_meta
http://codex.wordpress.org/Function_Reference/update_post_meta

I'd say there is barely enough information in the question to speculate on an answer but it sounds like to me that...

You would pull the (I assume) serialized data with get_post_meta, alter the array/object to remove the key/value you want to delete, and then save the altered data with update_post_meta.

http://codex.wordpress.org/Function_Reference/get_post_meta
http://codex.wordpress.org/Function_Reference/update_post_meta

I'd say there is barely enough information in the question to speculate on an answer but it sounds like to me that...

If your data is saved in individual key/value pairs then delete_post_meta will do it. You would pass the function a post ID and a key name: delete_post_meta(1,'keyname');. It will delete the whole key/value pair.

If you have multiple bits of information saved as a serialized array/object then delete_post_meta will not work. You will need to pull the data for the key you want with get_post_meta, alter the array/object in PHP to remove the key/value you want to delete, and then save the altered data with update_post_meta.

http://codex.wordpress.org/Function_Reference/get_post_meta
http://codex.wordpress.org/Function_Reference/update_post_meta

Source Link
s_ha_dum
  • 65.5k
  • 13
  • 84
  • 174

I'd say there is barely enough information in the question to speculate on an answer but it sounds like to me that...

You would pull the (I assume) serialized data with get_post_meta, alter the array/object to remove the key/value you want to delete, and then save the altered data with update_post_meta.

http://codex.wordpress.org/Function_Reference/get_post_meta
http://codex.wordpress.org/Function_Reference/update_post_meta