Trying to determine in the loop if a post has a custom

Trying to determine in the loop if a post has a custom press type, and if it does to echo the category name….

Right now I have:

<?php
$category = get_the_category();
if($category[0]){
echo '<a href="' . esc_url(get_category_link($category[0]->term_id )) . '">' . esc_attr($category[0]->cat_name) . '</a>';
}
?>

It is displaying the name of the custom post type, but if it is a custom post type, I’d like it to echo the category, not just the post type….