code: protected function getFirstTerm(WP_Post $post)
      {
          $taxonomies = $this->getTaxonomies($post->post_type);
  
          foreach ($taxonomies as $taxonomy) {
              $post_terms = \get_the_terms($post, $taxonomy);
  
              if (!$post_terms || \is_wp_error($post_terms)) {
                  continue;
              }
  
              return $post_terms[0];
          }
      }
docs: Get post's first term