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 ); ?>

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:

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));

2 Answers 2


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;  
  • Actually, I'm confused now. Do you need the normal category taxonomy to be attached to custom posts, or do you just need to output descriptions for each of your categories (where category means an item in the normal WP category taxonomy)?
    – anu
    Commented Nov 19, 2010 at 19:29
  • Sorry to be confusing! I need the categories I created for the custom posts. So, it's a taxonomy just for these posts. Does that make sense? Commented Nov 19, 2010 at 20:33
  • gotcha - editing my answer with what I think you need
    – anu
    Commented Nov 19, 2010 at 21:07
  • Thanks, Anu. Sorry to be a php nitwit, but I tried this and got nothing: '<?php wp_get_post_terms('20', 'toolkit', 'description') ?>' should I have left it as '<?php wp_get_post_terms($post->ID, 'toolkit', 'description') ?>' ? Commented Nov 21, 2010 at 15:44
  • Added a quick code fragment
    – anu
    Commented Nov 21, 2010 at 18:05

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.

  • Thanks, MathSmath, I will try that. I was being a tad literal minded! Code is above, thank you again. Commented Nov 19, 2010 at 17:57
  • MathSmath, I added the following and still don't get the cat description. I am doing something dumb, right? <?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 echo category_description('20'); ?> <?php endwhile; endif; wp_reset_query(); ?> Commented Nov 19, 2010 at 20:34
  • Jeff, please add the loop's code inside your original question as it is much better to read then.
    – hakre
    Commented Nov 19, 2010 at 22:12
  • I think category_description() only works for the default category taxonomy - not a custom taxonomy
    – anu
    Commented Nov 21, 2010 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.