toggle menu

How to get fields value of post_type taxonomy terms?

Dhananjay Kumar |22 Mar at 06:03

In Wp-admin we have created a post_type and taxonomy. In taxonomy added lots of terms data with additional fields. We want to show that fields value in front end behalf of a slug.

  • 2 likes
  • 1 comment

Sanjana Kumari22 Mar at 06:03

Please use this below code, its help you
//$current_id = get_the_ID();
$uri=explode("/",$_SERVER['REQUEST_URI']);
//print_r($uri);
$slug=$uri[2]; // slug getting from address of URL
$taxonomy_names = get_term_by('slug',$slug,'taxonomy_name_pass');
// print_r( $taxonomy_names );
echo $taxonomy_names->term_id
echo $taxonomy_names->name
echo $taxonomy_names->description
// for use with advance or custome fields below query
$term_meta = get_term_meta( $taxonomy_names->term_id );
echo $term_meta[fileds_name][0];
?>

Posted:

22 Mar at 06:03

Viewed:

3773 times

Active:

26 Mar at 01:03