Skip to content

Instantly share code, notes, and snippets.

@caratage
Created November 23, 2012 19:28
Show Gist options
  • Save caratage/4136955 to your computer and use it in GitHub Desktop.
Save caratage/4136955 to your computer and use it in GitHub Desktop.
Manage custom posts columns, show custom taxonomies
add_action("manage_posts_custom_column", "artist_custom_columns");
function artist_custom_columns($column) {
global $post;
switch ($column) {
case "performance":
$_taxonomy = 'artist_performance';
$terms = get_the_terms( $post_id, $_taxonomy );
if ( !empty( $terms ) ) {
$out = array();
foreach ( $terms as $c )
$out[] = esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display'));
echo join( ', ', $out );
}
else {
echo "n/a";
}
break;
case "city":
$custom = get_post_custom();
if ($custom["_artist_city"]) {
echo $custom["_artist_city"][0];
echo " (";
echo $custom["_artist_country"][0];
echo ")";
} else {
echo "n/a";
}
break;
case "musiclabel":
$custom = get_post_custom();
if ($custom["_artist_label"]) {
echo $custom["_artist_label"][0];
} else {
echo "n/a";
}
break;
case "slides_home":
$custom = get_post_custom();
if ($custom["_artist_slides_home"]) {
echo $custom["_artist_slides_home"][0];
} else {
echo "n/a";
}
break;
case 'thumbnail':
if ( has_post_thumbnail()) {
the_post_thumbnail(array(100,100));
} else {
echo "n/a";
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment