Last active
March 21, 2017 20:02
-
-
Save marcosnakamine/6301c3277c203735e44f93e23d9e6776 to your computer and use it in GitHub Desktop.
WordPress - Add new columns in dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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