[wp-trac] [WordPress Trac] #35502: post_name does not get added when using post_status other than publish
WordPress Trac
noreply at wordpress.org
Sun Jan 17 21:43:06 UTC 2016
#35502: post_name does not get added when using post_status other than publish
-------------------------------+-----------------------------
Reporter: Jossnaz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 4.4.1
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
the beautiful documentation on
https://codex.wordpress.org/Function_Reference/wp_insert_post lacks
elementary information.
post_name does NOT get inserted when using a normal editor user (not wp-
admin) and using this code
{{{#!php
<?php
$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);
}}}
this is NOT stated in the docs.
This works:
{{{#!php
<?php
$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);
}}}
now how does wordpress itself store the slug before it is published?
obviously, not in post_name.
If you feel good, feel free to answer on
http://wordpress.stackexchange.com/questions/214810/post-name-is-not-
stored-until-post-is-published-where-should-i-store-my-slug
as I am not the only one wondering about this defect.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35502>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list