WordPress trick: Get category slug using category ID
Posted by The Farmer on Jan 28, 2011 in Wordpress | 0 comments
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. Thanks to Ken Rosaka for the tip! Looking for WordPress...
Read More






