update_post_meta not saving empty value - wordpress

cipriano Source

I am trying to remove a post meta value. This is my code:

update_post_meta( $post_id, 'gcal_event_id', '' );

It's not saving. How can i solve this?

phpwordpressmetadata

Answers

answered 4 months ago August Miller #1

According to the Wordpress Codex, there is also a delete_post_meta function that is used for removing post meta values.

Passing the third argument deletes only the meta values that equal the one provided. If you want to remove all of a post’s meta values for the given key, omit the third argument.

comments powered by Disqus