Taxonomy in custom post column

<?php

/* Add Columns */
function wco_add_columns($defaults){
if($_GET['post_type'] != 'wco_vendor') return $defaults;
$defaults['wco_region'] = __('Region');
return $defaults;
}

/* Get Column Data */
function wco_get_column_data($column,$id){
switch($column){
case 'wco_region':
wco_term_links($id,'wco_region');
break;
}
}

/* Term Links */
function wco_term_links($id,$taxonomy){
$terms = wp_get_object_terms($id,$taxonomy);
$count = count($terms);
$i = 1;
if($count > 0){
foreach($terms as $term){?>
<a href="/wp-admin/edit-tags.php?action=edit&taxonomy=<?php echo $taxonomy . '&tag_ID=' . $term->term_id ?>&post_type=wco_vendor"><?php echo $term->name ?></a><?php if($i < $count) echo ','; $i++ ?>
<?php
}
}
}

add_filter('manage_wco_vendor_posts_columns','wco_add_columns');
add_action('manage_wco_vendor_posts_custom_column','wco_get_column_data',10,2);
?>

1 Comment

You must be logged in to post a comment.


  1. Appreciate it for helping out, great information. fkgggabckged