get_object_taxonomies()
by default returns a list of taxonomy names like category
and post_tag
. If you want the function to return taxonomy objects instead, then set the second parameter to objects
:
$taxonomies = get_object_taxonomies($custom_post_type_name, 'objects');
And then change your foreach ()
code to foreach ($taxonomies as $taxonomy => $tax_object)
, then use $tax_object->labels->singular_name
to access the singular label of the specific taxonomy.