WordPress category ID to name

07.Oct.2010

In order to convert category ID to category name in WordPress, you can use get_cat_name(). This is a WordPress function that will help you get category name based on category ID. It can be used when you know category name might be changed, and you know ID will stay the same.

See snippet below in order to get category name by ID in WordPress.

1
2
3
4
$category_id = 4; //replace with your category ID
echo '<a href="' . get_category_link($category_id) . '">';
echo get_cat_name($category_id);
echo '</a>';