update_post_meta()
不断向数组中添加,而不是替换值。有什么建议吗?
以前我用过add_post_meta()
这是偶然的,也许它以某种方式将场标记为一个数组?
更新,那么如何将元字段设置为非数组?
代码:
$lowjobtrig = 1;
foreach ( $values as $value ) :
//====================myedit==================
if ($key == \'public_paywall\') {
if ($value == \'paywall\') {
add_post_meta($postId, $key, $value, /*unique=*/ false);
} elseif ($value == \'public\'{
add_post_meta($postId, $key, $value, /*unique=*/ false);
}
} elseif ($key == \'pay_offer\') {
if ($value == \'pay\') {
add_post_meta($postId, $key, $value, false);
} elseif ($value == \'no pay\') {
add_post_meta($postId, $key, $value, false);
} else {
}
} elseif ($key == \'low_jobs\' AND $value == \'under 100\'){
$lowjobtrig = 1;
update_post_meta($postId, $key, \'under 100\');
} elseif ($key == \'low_jobs\' AND $value != \'under 100\' AND $lowjobtrig == 0){
add_post_meta($postId, $key, \'OVER 100\', true);
$lowjobtrig = 1;
}
else {
FeedWordPress::diagnostic(\'syndicated_posts:meta_data\', ">>>>>>>>>>ELSE Adding post meta-datum to post [$postId]: [$key] = ".MyPHP::val($value, /*no newlines=*/ true));
add_post_meta($postId, $key, $value, /*unique=*/ false);
}