I added slug input field in my custom post type and allow users to edit it at front end. Then, when insert post, I use this:

$wp_insert_post_args = array(
            'post_status'   => 'publish',
            'post_type' => MY_POST_TYPE,
            'post_author'   => $this->creator_id,
            'post_title'    => $this->name
            'post_name'     => sanitize_title( $this->slug ) 
            );

My custom post type already suports 'title', so, it suppose to auto generate post_name. Now I add $slug as 'post_name' as described above, will woredpress use 'title' to generate 'post_name', or use my 'slug'? will wordpress perform slug exist checking as it does on normal posts, or should I take care of the checking myself?

link|improve this question

66% accept rate
feedback

1 Answer

up vote 0 down vote accepted

If the slug exsit WordPress will add a number to the end. For example if you had two post named "test" you would get "test" and "test-1"

Hope that helps

link|improve this answer
so, I don't need to perform a check? Also no need to apply some safty filter? – Jenny Dec 24 '11 at 9:19
Nope, WP has your back. You might want to perform a check if the numbers at the end bug you. – BandonRandon Dec 24 '11 at 20:36
Thanks, I will try it out. still not sure if wordpress will use 'title' or my slug input to generate the post name, but a test will tell. – Jenny Dec 25 '11 at 0:44
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.