Skip to content

Instantly share code, notes, and snippets.

@marcosnakamine
Last active March 21, 2017 20:02
Show Gist options
  • Save marcosnakamine/6301c3277c203735e44f93e23d9e6776 to your computer and use it in GitHub Desktop.
Save marcosnakamine/6301c3277c203735e44f93e23d9e6776 to your computer and use it in GitHub Desktop.
WordPress - Add new columns in dashboard
<?php
// REGISTER THE COLUMN
add_filter('manage_contatos_posts_columns', 'posts_columns');
function posts_columns($defaults){
unset($defaults['post_date']);
$defaults['email'] = 'E-mail';
return $defaults;
}
// RENDER THE COLUMN
add_action('manage_contatos_posts_custom_column', 'posts_custom_columns', 5, 2);
function posts_custom_columns($column_name, $post_id){
if($column_name === 'email'){
echo get_post_meta($post_id,'email', true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment