Skip to content

Instantly share code, notes, and snippets.

@kristarella
Created August 19, 2013 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristarella/6266446 to your computer and use it in GitHub Desktop.
Save kristarella/6266446 to your computer and use it in GitHub Desktop.
Function to add your custom taxonomy as a column in the All Posts view of a custom post type (where "location" is the custom post type and "state" is the taxonomy).
<?php
add_filter('manage_location_posts_columns' , 'add_post_columns');
add_action( 'manage_location_posts_custom_column' , 'state_column', 10, 2 );
function add_post_columns($columns) {
$columns['state'] = 'State/Territory';
return $columns;
}
function state_column( $column, $post_id ) {
switch ( $column ) {
case 'state' :
$terms = get_the_term_list( $post_id , 'state' , '' , ',' , '' );
if ( is_string( $terms ) )
echo $terms;
else
echo '';
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment