cipriano
cipriano

Reputation: 111

update_post_meta not saving empty value - wordpress

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?

Upvotes: 0

Views: 1645

Answers (1)

August Miller
August Miller

Reputation: 1968

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.

Upvotes: 2

Related Questions