WP:update_post_metaは、add_post_metaの機能も持つ

WordpressのCodex より

The function, update_post_meta(), updates the value of an existing meta key (custom field) for the specified post.

This may be used in place of add_post_meta() function. The first thing this function will do is make sure that $meta_key already exists on $post_id. If it does not, add_post_meta($post_id, $meta_key, $meta_value) is called instead and its result is returned.

Returns meta_id if the meta doesn’t exist, otherwise returns true on success and false on failure. It also returns false if the value submitted is the same as the value that is already in the database.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です