在使用插入帖子时,我试图将用户元字段添加到帖子自定义字段wp_insert_post()
但它不起作用。我试过更换$branch
使用一个简单的字符串,它可以工作,但当我使用wpcf-branch-active
在里面什么也看不出来。
谁能帮帮我吗?
$my_order = array (
\'post_type\' => \'saved-orders\',
\'post_title\' => date(\'Y-m-d\'),
\'post_content\' => $ordercart,
\'post_status\' => \'publish\',
\'comment_status\' => \'closed\', // if you prefer
\'ping_status\' => \'closed\', // if you prefer
);
$post_id = wp_insert_post($my_order);
$user_id = get_current_user_id();
$branch = get_user_meta($user_id, "wpcf-branch-active", true);
add_post_meta($post_id, \'wpcf-branch-order\', $branch, true);