I am trying to get the category name of a custom post type category in my single-[cpt].php file.
Here is the code I am using:
$queried_object = get_queried_object();
$term_name = $queried_object->name;
echo $term_name;
The category is a sub category. This code just displays the name of the parent category, where I need the name of the category.