Assumptions:
institute
is the taxonomycourse
is the term- only one
course
is assigned per post - you want to display the course description?
If so, the simplest way would be to use get_the_terms()
. If your taxonomy is institute
, you can do something like the following:
<?php
// globalize $post
global $post;
// Get the course for the current post
$post_courses = get_the_terms( $post->ID, 'institute' );
// Assuming only one course, get the first object of the array
$post_course = $post_courses[0];
// Get the course description
$course_description = $post_course->description;
// Output the course description
echo $course_description
?>
If my assumptions are incorrect, then let me know in the comments, and I’ll update the answer.
EDIT
Other assumption is all right but I want to show “institute description”. Only one course is assigned per post but each institute contains several courses. Institute is taxonomy and name of institutes are used as categories.
I’m still not entirely sure that I’m following you. Are you saying that institute
and course
are hierarchical taxonomies? If so, then my original assumptions are incorrect. Can you more clearly describe your schema?
EDIT 2
In this case, I want to show description of university of Auckland. While this university is also used in many other posts. In my case, each course is a post.
Okay, now we’re getting somewhere! It seems that course
is a Custom Post Type, and that institute
is a Custom Taxonomy for that CPT. If this is correct, then my above code should work for displaying the term description for a given post.