Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top