Delete custom fields when deleting posts
The best way to do this is to use the wp_delete_post function as follows: wp_delete_post($post_id, true); //false (default) sends it to the trash This function accounts for comments, term_relationships, posts.post_parent, and postmeta.