Created
August 19, 2013 07:19
-
-
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).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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