I was testing and found a way to get the name, but it is not very efficient because it has to go through a loop. Is there another more efficient way?
I can use any id, slug or name.
if ( is_singular( 'hp_listing' ) ) {
$listing = \HivePress\Models\Listing::query()->get_by_id( get_queried_object_id() );
if ( $listing && $listing->get_categories__id() ) {
foreach ( $listing->get_categories() as $category ) {
$category_name = $category->get_name();
}
}
}