Link of first category page of a custom post from single page

Share Now


<?php 
   $terms = get_the_terms( $post->ID, 'material-category' );
   if ( !empty( $terms ) ){
   // get the first term
   $term = array_shift( $terms );
   $link = get_term_link( $term );
   }
?>
<a href="<?php echo $link; ?>">category Link</a>

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert