Listing taxonomy terms of a custom post type

I have created a custom post type with a custom taxonomy called ‘sp_casestudy_category’ like so:

function zen_create_casestudy_taxonomies()
{
$labels = array(
    ...
);

register_taxonomy("sp_casestudy_category", array("zen_casestudy"), array(
    'hierarchical' => true,
    'public' => true,
    'show_in_nav_menus' => true,
    'labels' => $labels,
    'rewrite' => true,
    'query_var' => true,
    'rewrite' => array('slug' => 'casestudy/category')
));
}
add_action( 'init', 'sp_create_casestudy_taxonomies', 0 );

This seems to work fine, I can assign posts to these categories. However within another custom post type I am trying to list these terms in checkboxes so I can let the user choose which category to display the post on. For example the code is something like below to do this:

Read More
foreach ($meta_fields_category_sbteaser as $field) {

    $options = $field['options'];
    $meta = get_terms($options['taxonomy']);

    switch ($field['type']) {

    case 'checkbox':
        foreach ($terms as $term) {
            echo '<input type="checkbox" name="'.$field['id'].'" value="" /><br/>';
        }
    break;

    } //end switch

} // end foreach

However I cannot get this to work. How would I list these categories in a custom meta box?

Thanks
Robert

Related posts

Leave a Reply