WordPress trick: Get category slug using category ID
February 28th, 2011 at 12:35am Jason 336 views
First, put the following function in your functions.php file:
function get_cat_slug($cat_id) { $cat_id = (int) $cat_id; $category = &get_category($cat_id); return $category->slug; }
Once done, you can call the function as shown below:
<?php echo get_cat_slug(3); ?>
This will display the slug for the category with the ID 3.
via: http://www.wprecipes.com/wordpress-trick-get-category-slug-using-category-id
Entry Filed under: WordPress Tagged with: category wordpress
Hot Posts Hot Comments Hot Tags
- apartment bbpress blog class CMS code CSS div dream english friends girl Google hot Hot Dog html job JS life lines love Madonna menu Michael Jackson movie oral english PHP plugin saying school sexy site student students submenu success tags teacher teaching txt university video website widget wordpress





Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
Trackback this post | Subscribe to the comments via RSS Feed