Definition:
function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {}
Update post meta field based on post ID.
Use the $prev_value parameter to differentiate between meta fields with the same key and post ID.
Parameters
- int $post_id: Post ID.
- string $meta_key: Metadata key.
- mixed $meta_value: Metadata value.
- mixed $prev_value: Optional. Previous value to check before removing.
Return values
returns:False on failure, true if success.
Source code
function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') { // make sure meta is added to the post, not a revision if ( $the_post = wp_is_post_revision($post_id) ) $post_id = $the_post; return update_metadata('post', $post_id, $meta_key, $meta_value, $prev_value); }
3199
No comments yet... Be the first to leave a reply!