我遇到了这个问题,我就是这样解决的:
在我的例子中,我想向现有序列化数据添加一个数组:

我想将使用Ajax发布的新数组数据添加到现有
meta_key
.
Note : 现有meta\\u密钥为\'accordions\'
function save_new_data(){
// Step 1: get the data you want to add (can be from an ajax post like my case)
$posted_data = $_POST;
//clean it up like remove what you don\'t want like the action from ajax post
$new_data = array_diff_key($posted_data, [\'action\' => "xy", ]); //optional
//Step 2: get the existing data
$existing_data = get_post_meta(get_the_ID(), "accordions", true);
//Step 3: check if its an array, add new data to the existing data then update_post_meta()
if(is_array($existing_data)) {
$existing_data[] = $save_data;
update_post_meta(get_the_ID(), \'accordions\', $existing_data );
}
}