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?
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?
Share Improve this question edited Dec 24, 2011 at 9:34 Jenny asked Dec 24, 2011 at 8:18 JennyJenny 1,7674 gold badges27 silver badges41 bronze badges1 Answer
Reset to default 0If 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