我可以使用表单成功创建WordPress自定义帖子。我遇到的问题是我无法将post meta变为自定义帖子类型。
在我的表单处理器文件中:
$custom1 = isset($_POST['custom1']) ? $_POST['custom1'] : '';
$custom2 = isset($_POST['custom2']) ? $_POST['custom2'] : '';
require_once('../../../wp-load.php');
//Insert form data into post array
$post_information = array(
'post_title' => wp_strip_all_tags($title),
'post_content' => $description,
'post_type' => 'review-listing',
'post_status' => 'draft'
);
wp_insert_post($post_information);
if ($post_id) {
// insert post meta
add_post_meta($post_id, 'custom1', $custom1);
add_post_meta($post_id, 'custom2', $custom12);
}
谢谢,