wordpress - WP No slug when adding a pending post -


i'm using following snippet of code add post:

$post_args = array(     'post_content'   => 'test test',     'post_name'      => 'slughere',     'post_title'     => 'title',     'post_status'    => 'pending',     'ping_status'    => 'closed',     'comment_status' => 'closed' );  $new_post_id = wp_insert_post( $post_args ); 

if add post 'publish' status, works. when post 'pending' post, reason slug not being added. stays empty.

does have idea how possible of why happening?

running latest wp , updated core again sure there nothing weird going on there.

if want add parameter post_name manually make sure sanitize , assure uniqueness,

so try following code:-

$post_args = array(         'post_content'   => 'test test',         'post_name'   => wp_unique_post_slug( sanitize_title( 'slughere' ) ),         'post_title'     => 'title',         'post_status'    => 'pending',         'ping_status'    => 'closed',         'comment_status' => 'closed' );  $new_post_id = wp_insert_post( $post_args ); 

hope help.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -