0
我做这个简单的代码中添加一个新的职位,以WordPress的DB(外循环):WordPress - 如何添加/更新post_meta(自定义字段)?
include_once './wp-config.php';
include_once './wp-load.php';
include_once './wp-includes/wp-db.php';
$upname = 'TestName';
$updescription = 'Description';
// Create post object
$my_post = array();
$my_post['post_title'] = $upname;
$my_post['post_content'] = $updescription;
$my_post['post_status'] = 'draft';
$my_post['post_author'] = 1;
if (current_user_can('manage_options')) {
// Insert the post into the database
wp_insert_post($my_post);
echo '<br /><b>The Advertisement is saved as Draft!</b>';
} else {
echo '<br /><b>You are NOT logged in, login to continue!</b>';
}
它的工作原理100%,但现在我要补充2自定义字段:“PHONE_NUM”和“ birth_date“
如何在此代码中添加自定义字段?
检查http://stackoverflow.com/questions/4901544/wp-insert-post-php-function-and-custom-fields –