WP Plugins and Custom Fields
This article is intended to address issues involving the use of add_post_meta and delete_post_meta in WordPress plugin design. These functions can be used to add or delete custom fields for a post, useful for plugin design as the value for the custom field can be entered via a form in the write page. The add_post_meta code would look something like this:






Erm, have you tried update_post_meta ?
Hi Johnbillion,
update_post_meta is a tidier way, true. But the problem still remains that if you hook it in using add_action as stated above, there will be instances where the function is called even though the form hasn’t been submitted (i.e. the post/page hasn’t been edited), like when a comment is approved.
Sam