Skip to content

Instantly share code, notes, and snippets.

@rbk
Created October 30, 2013 16:37
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 rbk/7235827 to your computer and use it in GitHub Desktop.
Save rbk/7235827 to your computer and use it in GitHub Desktop.
Modify post columns in wordpress
<?php
// modify post columns
add_filter('manage_guru_employees_posts_columns', 'employees_posts_columns', 5);
add_action('manage_guru_employees_posts_custom_column', 'employee_custom_columns', 5, 2);
function employees_posts_columns($columns){
unset( $columns['riv_post_thumbs'] );
unset( $columns['date'] );
$columns['phone_number'] = __('Phone');
$columns['profile_image'] = __('Picture');
$columns['title'] = __('Employee Name');
$columns['hire_date'] = __('Hire Date');
$columns['email_address'] = __('Email Address');
return $columns;
}
function employee_custom_columns($column_name, $id){
if( $column_name === 'email_address' ){
$email = get_field('email_address', $id );
echo '<a href="mailto:' . $email . '">'. $email .'</a>';
}
if( $column_name === 'hire_date' ){
$date = get_field('hire_date',$id);
echo date( 'M dS Y', strtotime( $date ) );
}
if( $column_name === 'profile_image'){
echo '<img src="' . get_field( $column_name, $id )['sizes']['thumbnail'] . '"/>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment