• 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)
  • 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..
    https://codex.www.ads-software.com/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 ??

    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.