Skip to content

Instantly share code, notes, and snippets.

@spencejs
Last active December 15, 2015 06:49
Show Gist options
  • Save spencejs/5218750 to your computer and use it in GitHub Desktop.
Save spencejs/5218750 to your computer and use it in GitHub Desktop.
Add Column With A Custom Field To Wordpress Admin Post Listing
///////////////////////////////////////////////////////////
//Custom Backend Column from Custom Field. Be sure to edit post-type- "manage_edit-POSTTYPE_columns"- and Custom Field Name.
///////////////////////////////////////////////////////////
add_filter('manage_edit-staff_columns', 'my_columns');
function my_columns($columns) {
unset($columns['author']);
unset($columns['date']);
$columns['Name'] = 'Name';
$columns['author'] = 'Author';
$columns['date'] = 'Date';
return $columns;
}
add_action('manage_posts_custom_column', 'my_show_columns');
function my_show_columns($name) {
global $post;
switch ($name) {
case 'Name':
$views = get_post_meta($post->ID, 'Name', true);
echo $views;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment