2015-12-23 129 views
0

问题:是否可以像使用update_post_meta()一样使用函数来更新WordPress帖子的元框值?使用某些WordPress功能更新Meta Box值。可能?

说明: 这里是因为我想用一个函数/钩来更新metabox保存在数据库中的数据的格式。 enter image description here

现在,如果我想更新只从数据单一入口,让说“START_YEAR”话,我怎么能做到这一点使用函数/挂钩?

如果我选择使用update_post_meta(65,'_mycpt_date','2010),它显然会取代所有内容,只是'2010'。

回答

0

在做了一些头脑风暴和this的帮助之后,我用一点办法解决了这个问题。

// Storing the value/array in the variable. 
    $options = get_post_meta(65, '_chronos_date', true); 

// Updating the new value using key-value pair. That way, other parts of the array would remain un-touched. 
    $options['start_year']= "2000"; 

// Update the new value. 
update_post_meta(65,'_chronos_date',$options); 

很快。我希望它能帮助别人。