admin管理员组文章数量:1122846
important try as normal contributor user, not as admin
see here I actually have it reproduced. Seems like a bug to me but whatever. I want users to choose their slug. Well, as you cannot store post_name in pending posts, where should I store it? where does wordpress store the slug the user chooses while it is still draft / pending?
EDIT
my code, this works as it is publish status:
$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);
this does not work
$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);
in case 2, post_name is empty string after insert.
the author doesn't matter
important try as normal contributor user, not as admin
see here I actually have it reproduced. Seems like a bug to me but whatever. I want users to choose their slug. Well, as you cannot store post_name in pending posts, where should I store it? where does wordpress store the slug the user chooses while it is still draft / pending?
EDIT
my code, this works as it is publish status:
$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);
this does not work
$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);
in case 2, post_name is empty string after insert.
the author doesn't matter
Share Improve this question edited May 23, 2017 at 12:40 CommunityBot 1 asked Jan 17, 2016 at 20:51 ToskanToskan 5242 gold badges8 silver badges23 bronze badges 1- please post your code. anyway that code does not set an author which might or might not be the issue.there – Mark Kaplun Commented Jan 17, 2016 at 21:12
1 Answer
Reset to default 0When you use the graphical interface, post_name
is stored in the wp_posts
table even for draft posts as soon as you modify the default value.
I tried your code (case 2) and I actually see the new entry in the database, with the correct post_name
. Perhaps your check to post_name is not correct ?
本文标签:
版权声明:本文标题:permalinks - post_name is not stored until post is published... where should I store my slug until it goes live then? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736293240a1929104.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论