update_meta

Update post meta data by meta ID.

Description

update_meta( (int) $meta_id, (string) $meta_key, (string) $meta_value ); 

Parameters (3)

0. $meta_id (int)
The meta id.
1. $meta_key (string)
Expect Slashed
2. $meta_value (string)
The meta value.

Usage

  1. if ( !function_exists( 'update_meta' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/post.php'; 
  3.  
  4. // The meta id. 
  5. $meta_id = -1; 
  6.  
  7. // Expect Slashed 
  8. $meta_key = ''; 
  9.  
  10. // The meta value. 
  11. $meta_value = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = update_meta($meta_id, $meta_key, $meta_value); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/post.php  
  1. function update_meta( $meta_id, $meta_key, $meta_value ) { 
  2. $meta_key = wp_unslash( $meta_key ); 
  3. $meta_value = wp_unslash( $meta_value ); 
  4.  
  5. return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key );