I using post meta like..

$meta = get_post_meta(99,'_mymeta',true);
$value = $meta['somekey'];
echo $value;

But how to update $meta['somekey'] to some another value ?

How to use update_post_meta to update sub meta key ?(Idk, How ppl call)

update_post_meta(99, '_mymeta["somekey"]', 'myAnotherValue');


1 Answer 1


To update post meta that are an array: you have to fetch the original values, change the value you need and update it again. For example

$list_of_values = get_post_meta($post_id, '_list_values', true);
if(!empty($list_of_values)) {
    $list_of_values["some_prop"] = "new value";
update_post_meta($post_id, '_list_values', $list_of_values);
  • Thanks so much , What about deleting an array ?
    – l2aelba
    May 14, 2013 at 8:58
  • 2
    @l2aelba: you can either set the value to empty, or do unset($list_of_values["element_to_delete"]);
    – Angela
    May 14, 2013 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.