WPSEO_Meta::set_value()public staticYoast 1.0

Update a meta value for a post.

Метод класса: WPSEO_Meta{}

Хуков нет.


true|false. Whether the value was changed.


$result = WPSEO_Meta::set_value( $key, $meta_value, $post_id );
$key(строка) (обязательный)
The internal key of the meta value to change (without prefix).
$meta_value(разное) (обязательный)
The value to set the meta to.
$post_id(int) (обязательный)
The ID of the post to change the meta for.

Код WPSEO_Meta::set_value() Yoast 22.1

public static function set_value( $key, $meta_value, $post_id ) {
	 * Slash the data, because `update_metadata` will unslash it and we have already unslashed it.
	 * Related issue: https://github.com/Yoast/YoastSEO.js/issues/2158
	$meta_value = wp_slash( $meta_value );

	return update_post_meta( $post_id, self::$meta_prefix . $key, $meta_value );