当我使用post状态调用wp\\u insert\\u post()时,它只创建具有“Draft”状态的帖子。我已经用WordPress的内置状态和我的自定义帖子状态对它进行了测试。但它只会创建草稿帖子,我不能将其从WordPress中丢弃或删除。这是我的密码。请帮忙。
// Prepare to save!
do_action( \'wpo_frontend_before_save_order\', $order_details, $user_details );
$post = array(
\'post_title\' => $order_details[\'title\'],
\'post_author\' => get_current_user_id(),
\'post_type\' => \'wp_order\',
\'post_status\' => \'pending\'
);
$postID = wp_insert_post( $post );
if ( is_wp_error( $postID ) ) {
set_transient( \'wpo_new_order_message_\' . get_current_user_id(), __( \'There was a problem to register your order. Please try again later\', \'wpo\' ) );
return;
}
SO网友:TBI Infotech
代码仅创建草稿的原因是status=\'pending\'使其发布
喜欢//准备保存!
do_action( \'wpo_frontend_before_save_order\', $order_details, $user_details );
$post = array(
\'post_title\' => $order_details[\'title\'],
\'post_author\' => get_current_user_id(),
\'post_type\' => \'wp_order\',
\'post_status\' => \'publish\'
);
$postID = wp_insert_post( $post );
if ( is_wp_error( $postID ) ) {
set_transient( \'wpo_new_order_message_\' . get_current_user_id(), __( \'There was a problem to register your order. Please try again later\', \'wpo\' ) );
return;
}