update_meta() WordPress Function

The update_meta() function is used to update metadata for a given object. This function can be used to update any arbitrary metadata for an object, but is most commonly used to update post meta data.

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

Updates post meta data by meta ID.


Parameters

$meta_id

(int)(Required)Meta ID.

$meta_key

(string)(Required)Meta key. Expect slashed.

$meta_value

(string)(Required)Meta value. Expect slashed.


Top ↑

Return

(bool)


Top ↑

Source

File: wp-admin/includes/post.php

function update_meta( $meta_id, $meta_key, $meta_value ) {
	$meta_key   = wp_unslash( $meta_key );
	$meta_value = wp_unslash( $meta_value );

	return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key );
}


Top ↑

Changelog

Changelog
VersionDescription
1.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More