I have created a custom post type: register_post_type() and custom taxonomy: register_taxonomy(), but when trying to show the categories made to the post type in the theme single-{post_type}.php they do not appear.

I am using this but without success:

$categories = get_the_category($post->ID);

foreach($categories as $category){
  echo $category->name;

1 Answer 1


Try using get_the_terms() instead of get_the_category(). The latter is for the default "category" taxonomy only, not custom taxonomies you register yourself. See developer.wordpress.org/reference/functions/get_the_terms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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