Title: single_cat_slug()?
Last modified: August 19, 2016

---

# single_cat_slug()?

 *  Resolved [andrewjmonks](https://wordpress.org/support/users/andrewjmonks/)
 * (@andrewjmonks)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/single_cat_slug/)
 * I’m looking for a function that’s the same as single_cat_title() but which returns
   the category’s slug rather than title.
 * I’d be using it on category.php, in template tags outside the loop.
 * Does any such function exist? I’ve tried single_cat_slug() to no avail. If not,
   is there another way of getting the slug?
 * Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Edward Caissie](https://wordpress.org/support/users/cais/)
 * (@cais)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/single_cat_slug/#post-1803898)
 * I use this in one of my themes (in the category.php template):
 *     ```
       <?php /* used to create dynamic category link */
       $curr_cat = single_cat_title( '', false );
       $cat_id = get_cat_ID( $curr_cat );
       $category_link = get_category_link ( $cat_id );
       ?>
       ```
   
 * You could probably strip out the category slug from the end of the ‘$category_link’
   if you need the slug only.
 *  Thread Starter [andrewjmonks](https://wordpress.org/support/users/andrewjmonks/)
 * (@andrewjmonks)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/single_cat_slug/#post-1803899)
 * Awesome, I think that would work. Thanks
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/single_cat_slug/#post-1803900)
 * another possibility:
 * `<?php $cat = get_term_by('name', single_cat_title('',false), 'category'); echo
   $cat->slug; ?>`
 * [http://codex.wordpress.org/Function_Reference/get_term_by](http://codex.wordpress.org/Function_Reference/get_term_by)
 *  Thread Starter [andrewjmonks](https://wordpress.org/support/users/andrewjmonks/)
 * (@andrewjmonks)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/single_cat_slug/#post-1803904)
 * I like that even more! Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘single_cat_slug()?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [andrewjmonks](https://wordpress.org/support/users/andrewjmonks/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/single_cat_slug/#post-1803904)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
