Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




update_post_meta [ WordPress Function ]

update_post_meta ( $post_id, $meta_key, $meta_value, $prev_value = '' )
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.
Uses:
  • $wpdb
Links:
Returns:
  • (bool) False on failure, true if success.
Defined at:



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.

If the meta field for the post does not exist, it will be added.

Source


<?php
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);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics