The following snippet below will let you get category slug in WordPress.

Snippet Source/Credit: BestWPThemez.com