setPostMeta($postID, $data)

Update a post’s meta

Usage

site()->setPostMeta($postID, $data);

Parameters

ParameterTypeRequiredDescription
$postIDstringYesID of a post to update the meta of.
$dataarrayYesAn associative array of keys and values to apply to the post meta.

Example

Update key1 and key2 of the meta for post with ID 42

site()->setPostMeta(42, [
    "key1" => "value1",
    "key2" => "value2",
]);