Get parent categories of custom post type

If you’re in the single custom post template, you can get the terms that the post belongs to by use of

$terms = get_the_terms( get_the_ID(), 'btp_work_category' );

Then you need to determine parent term and display it with its children.

The code below assumes that the post belongs to one top category (term) and the taxonomy tree has no more than 2 levels.

$terms = get_the_terms( get_the_ID(), 'btp_work_category' );
if ( ! empty( $terms ) ) :
  echo "<ul>\n";
  // Parent term detection and display
  $term = array_pop( $terms );
  $parent_term = ( $term->parent ? get_term( $term->parent, 'btp_work_category' ) : $term );
  echo "<li>\n";
  echo '<a href="' . get_term_link( $parent_term, 'btp_work_category' ) . '">' . $parent_term->name . '</a>';
  // Getting children
  $child_terms = get_term_children( $parent_term->term_id, 'btp_work_category' );
  if ( ! empty( $child_terms ) ) :
    echo "\n<ul>\n";
    foreach ( $child_terms as $child_term_id ) :
      $child_term = get_term_by( 'id', $child_term_id, 'btp_work_category' );
      echo '<li><a href="' . get_term_link( $child_term, 'btp_work_category' ) . '">' . $child_term->name . "</a></li>\n";
    endforeach;
    echo "</ul>\n";
  endif; // ( ! empty( $child_terms ) )
  echo "</li>\n";
  echo "</ul>\n";
endif; // ( ! empty( $terms ) )