How to display category information from a custom post

I have created a page that uses custom posts: http://www.africanhealthleadership.org/resources/toolkit/

Each tool (Preparation, Assessment, etc.) is a custom post. On the WP Admin, each tool is a category; each category has a “description” field. I would like to output those descriptions on the Toolkit page. I tried using this and nothing displayed:
<?php echo category_description( $category ); ?>

Read More

Right now, the descriptions are hard-coded in to the page. The one for preparation begins
“Preparation tools establish…”

Thank you for any ideas!
Jeff


Here is the loop that spits out the custom post type:

<?php
query_posts( array( 'post_type' => 'portfolio', 'toolkit' => 'preparation' ) );
//the loop start here
if ( have_posts() ) : while ( have_posts() ) : the_post();
?>
<?php the_content(); ?>
<?php endwhile; endif; wp_reset_query(); ?>

And Here is the code from functions.php

add_action('init', 'portfolio_register');

function portfolio_register() {

$labels = array(
    'name' => _x('Toolkit', 'post type general name'),
    'singular_name' => _x('Tool', 'post type singular name'),
    'add_new' => _x('Add New Tool', 'tool'),
    'add_new_item' => __('Add New Tool'),
    'edit_item' => __('Edit Tool'),
    'new_item' => __('New Tool'),
    'view_item' => __('View Tool'),
    'search_items' => __('Search Toolkit'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''
);

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title','editor','thumbnail')
  ); 

register_post_type( 'portfolio' , $args );
}

register_taxonomy("toolkit", array("portfolio"), array("hierarchical" => true,   "label"     => "Tool Categories", "singular_label" => "Tool", "rewrite" => true));

Related posts

Leave a Reply

2 comments

  1. To get the taxonomy term for this particular post, then what you need is wp_get_post_terms($post->ID, 'yourtaxonomyname')

    This will return an array of terms in the specified taxonomy for the post specified. The codex page is: http://codex.wordpress.org/Function_Reference/wp_get_post_terms

    If you’re after a specific term in a taxonomy get_term($taxonomy_name, $term_id). You can also get all terms for a taxonomy using get_terms()

    Here’s an example of how to use it.

    $terms = wp_get_post_terms($post->ID,'toolkit');  
    foreach ($terms as $term) {  
        echo $term->description;  
    }  
    
  2. Make you’re passing the numeric category id into the category_description function.

    The value of the variable $category won’t fill itself automatically, if that’s what you were expecting. You need to set it for each category you output.

    If you post the relevant code (the loop you’re using to sipt out that category list), it’d be easier to troubleshoot.