
Untitled
By:
JTWilcox on
Jun 20th, 2011 | syntax:
PHP | size: 1.35 KB | hits: 321 | expires: Never
//Custom columns in Admin view
add_action("manage_posts_custom_column", "my_custom_columns");
add_filter("manage_edit-professionals_columns", "my_professionals_columns");
function my_professionals_columns($columns)
{
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Name",
"titles" => "Group",
"phone-o" => "Phone - Office",
"phone-c" => "Phone - Cell",
"email" => "Email",
"lastname" => "Last Name"
);
return $columns;
}
function my_custom_columns($column){
global $post;
switch($column){
case "phone-o":
$custom = get_post_custom();
echo $custom["prof_phone-o"][0];
break;
case "phone-c":
$custom = get_post_custom();
echo $custom["prof_phone-c"][0];
break;
case "email":
$custom = get_post_custom();
echo $custom["prof_email"][0];
break;
case "lastname":
$custom = get_post_custom();
echo $custom["prof_lastname"][0];
break;
case "titles":
// Get terms for post
$terms = get_the_terms( $post->ID , 'titles' );
// Loop over each item since it's an array
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->name . '<br />';
// Get rid of the other data stored in the object, since it's not needed
unset($term);
}
break;
}
}