Title: add_post_meta adding extra record in post_meta.
Last modified: August 19, 2016

---

# add_post_meta adding extra record in post_meta.

 *  [danleroux](https://wordpress.org/support/users/danleroux/)
 * (@danleroux)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/add_post_meta-adding-extra-field/)
 * Is it as expected that add_post_meta inserts an duplicate post in post_meta table
   in the database with a post_id of 0?
 * If Not what could be causing this:
 * my save_post action calls a function that includes this:
 *     ```
       if (!($saved_data == $submitted_data)){
       	if($saved_data == ''){
       		add_post_meta($post_id, 'recipe', $submitted_data, true);
       	}else{
       		update_post_meta($post_id, 'recipe', $submitted_data);
       	}
       }
       ```
   
 * update doesn’t seam to do it?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [fl3x7](https://wordpress.org/support/users/fl3x7/)
 * (@fl3x7)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/add_post_meta-adding-extra-field/#post-1271420)
 * im actually getting the same problem. Not quite sure whats causing it as i used
   some example wordpress code to do all my structuring etc..
    [http://codex.wordpress.org/Function_Reference/add_meta_box](http://codex.wordpress.org/Function_Reference/add_meta_box)
 * Everything works fine apart from the fact that each meta item is added twice 
   🙁
 * ive searched and noticed it was a bug which was fixed sometime ago, has it reappeared?
   🙁
 * hope someone can help, cheers 🙂
 *  [norbiu](https://wordpress.org/support/users/norbiu/)
 * (@norbiu)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/add_post_meta-adding-extra-field/#post-1271462)
 * Same problem, does anybody have a solution? That post_id = 0 in the wp_postmeta
   table is causing the fileds to show when adding a new post. When the fields are
   filled in and the post is published, the data isn’t inserted into the db.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘add_post_meta adding extra record in post_meta.’ is closed to new replies.

 * 2 replies
 * 3 participants
 * Last reply from: [norbiu](https://wordpress.org/support/users/norbiu/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/add_post_meta-adding-extra-field/#post-1271462)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
