In WordPress you can easily echo or display the title or the name of a Category like this:

<?php echo $category_name ?>

However, I've noticed that it does NOT display when I'm in a Custom Post Type. I'm using a popular plugin called "Custom Post Type UI"

Is anyone familiar on how to approach this, i.e. getting the Custom Post Type "category name" to display?


  • Make sure the category is displayed in the template file used by your custom post type. How do you determine the name of the category?
    – nmr
    Dec 14, 2019 at 8:35
  • $category_name is not a standard WordPress variable. Presumably it is defined by your theme, but maybe not in the template for your CPT. There is too little information in your question to determine what the problem is.
    – cjbj
    Dec 14, 2019 at 11:14

1 Answer 1


Are you talking about custom post type categories (i.e. terms)?

You can get existing term name by

$queried_object = get_queried_object();
$term_id = $queried_object->name;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.