important 尝试作为普通参与者用户,而不是管理员
看见here 我真的复制了它。对我来说似乎是个虫子,但不管怎样。我希望用户选择他们的slug。嗯,由于您不能在挂起的帖子中存储post\\u name,我应该将其存储在哪里?wordpress在用户选择的slug处于草稿/挂起状态时,将其存储在哪里?
EDIT
我的代码,按发布状态工作:
$post_information = array(
\'post_title\' => \'Your title\',
\'post_content\' => \'blabla\',
\'post_type\' => \'post\',
\'post_author\' => wp_get_current_user()->ID,
\'post_status\' => \'publish\',
\'post_name\' => "somerandomstuffthatisunique222"
);
$new_id = wp_insert_post( $post_information);
$postl = get_post($new_id);
这不起作用
$post_information = array(
\'post_title\' => \'Your title\',
\'post_content\' => \'blabla\',
\'post_type\' => \'post\',
\'post_author\' => wp_get_current_user()->ID,
\'post_status\' => \'pending\',
\'post_name\' => "somerandomstuffthatisunique2223434343434"
);
$new_id = wp_insert_post( $post_information);
在案例2中,插入后的post\\u name是空字符串。
作者不重要