function func_update_post_name( $post_id, $post ){ if ( 'post-type-slug' == $post->post_type ) { remove_action( 'save_post', 'func_update_post_name',30,2 ); // update the post slug wp_update_post( array( 'ID' => $post_id, 'post_name' => uniqid() )); add_action( 'save_post', 'func_update_post_name', 30, 2 ); } } add_action( 'save_post', 'func_update_post_name', 30, 2 );