The following snippet will let you set slug as string in WordPress.

Snippet Source/Credit: insitewebsitedesign.com