get category name info in custom post type single post page in wordpress

<?php
global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
  $product_cat_id = $term->term_id;
 
 
    $category_link = get_category_link( $product_cat_id );
 
  if( $term = get_term_by( 'id', $product_cat_id, 'product_cat' ) ){
    $cat_name=$term->name;
}
 
break;
}

Comments

Popular posts from this blog

dynamic create multiple ckeditor onclick event using jquery

get lat and long from city name using jquery

membership registration and login system in php