Get Taxonomy Description

Jon Imms
Jon Imms used Ask the Experts™
Hi there,
I have a custom XML feed, which displays all 2500 of our job posts.
for that, i have  a wordpress taxonomy created with PODS called Fleets (taxonomy=fleets)
I have 72 fleets, and all have descriptions.
How do I display the description of the current fleet?

I've tried :

Displays  -  Truck Driving Job
<title><![CDATA[<?php echo term_description( $post->ID, 'fleets'); ?> -  Truck Driving Job ]]></title>

Open in new window

		<title><![CDATA[<?php echo term_description( 'fleets'); ?> Truck Driving Job ]]></title>

Open in new window

Anybody know how to display correctly?

* Template Name: Custom RSS Template - spthuntfeed
$postCount = 500; // The number of posts to show in the feed
$cacheFile = "wp-content/themes/enfold/rsscache/spthuntfeed.rss";


$posts_per_page = 50;
$paged = 0;
$theres_more = true;
$rss_items = array();
if(file_exists($cacheFile) && !isset($_GET["reset"]))
  $rss_items = json_decode(file_get_contents($cacheFile),true);
  if($rss_items == null) { $rss_items = array(); }

$charset = get_option( 'blog_charset' );
header( 'Content-Type: ' . feed_content_type( 'rss-http' ) . '; charset=' . $charset, true );
<?php echo '<'.'?xml version="1.0" encoding="utf-8"?'.'>'; ?>
<title><?php bloginfo_rss( 'name' ); ?> - SmartPhoneTrucker - Hunt Transportation Job Feed</title>
<link><?php bloginfo_rss('url'); ?></link>
<description><?php bloginfo_rss('description'); ?></description>
<lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>

  $result = query_posts( array(
    'post_type' => 'job_listing',
    'paged' => $paged,
    'posts_per_page' => $posts_per_page,
    'tax_query' => array(
            'taxonomy' => 'job_listing_type', //or tag or custom taxonomy
            'field' => 'id',
            'terms' => array('499')
  ) );

  $number_of_results = count($result);

    // Get the next post

    // Check the cache
    if(isset($rss_items[$post->ID]) && (strtotime($rss_items[$post->ID][0]) == strtotime($post->post_modified)))
      // We have a cached item with the same modified date
      echo $rss_items[$post->ID][1];
      // Either the item isn't cached or the last-modified date has changed
	 	<referencenumber><![CDATA[<?php the_ID(); ?>]]></referencenumber>
		<title><![CDATA[<?php echo term_description( $post->ID, 'fleets'); ?> Truck Driving Job ]]></title>

		<date><![CDATA[<?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?>]]></date>
		<url><![CDATA[<?php the_permalink_rss(); ?>?utm_source=HuntSmartPhoneTruckerXMLFeed]]></url>
					// Use an output buffer to put the output of the_job_location() into a variable with the same name
					ob_start(); the_job_location(); $the_job_location = ob_get_clean(); 

					// Now extract the content between the ">" and the "<"
					$pos1 = strrpos($the_job_location, "<"); // Find the "<" of the "</a>" tag
					$pos2 = strrpos($the_job_location, ">", $pos1-strlen($the_job_location)) + 1; // Find the last ">" that occurs before the "</a>" tag
					$the_job_location = substr($the_job_location, $pos2, ($pos1-$pos2));

					// And display the text e.g. "Wheatland, WY, United States"
					//echo $the_job_location;
					echo preg_replace('/([^,]+).*/', '$1', $the_job_location );

			$mystr=get_the_term_list( $post->ID, 'states');
		<state><![CDATA[<?php echo $states; ?>]]></state>
			$mystr=get_the_term_list( $post->ID, 'job_listing_category');
					$mystr=substr($mystr,($temp_b+4));//add the number of characters in "</a>" which is 4
		<jobtype><![CDATA[<?php echo $drivertype; ?>]]></jobtype>
		<description><![CDATA[<?php the_excerpt(); echo do_shortcode( '[about-hunt]' ); ?>]]></description>
		<requirements><![CDATA[<?php echo do_shortcode( '[Qualifications]' ); ?>]]></requirements>



      // Get the item's RSS content and add it to the array
      $rss_item = ob_get_flush();
      $rss_items[$post->ID] = array($post->post_modified, $rss_item);

  // Save our updates after every page
  file_put_contents($cacheFile, json_encode($rss_items));

  // Check to see if there are more pages
  $theres_more = ($number_of_results == $posts_per_page);

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Web Developer
// Display Fleet Description for use in certain XML feeds.
function term_descriptionji() {
	$terms = get_the_terms( $post->ID, 'fleets');                           
		if ( $terms ) {
		// loop through artists (could be multiple)
			foreach ( $terms as $term ) {
		 		$termid = 'fleets_' . ($term->term_id);
		 		echo $term->description;

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial