WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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');


share|improve this question
up vote 4 down vote accepted

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);
share|improve this answer
Thanks so much , What about deleting an array ? – l2aelba May 14 '13 at 8:58
@l2aelba: you can either set the value to empty, or do unset($list_of_values["element_to_delete"]); – Angela May 14 '13 at 9:05
thanks so much @Angela – l2aelba May 14 '13 at 9:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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