Last active
December 15, 2015 06:49
-
-
Save spencejs/5218750 to your computer and use it in GitHub Desktop.
Add Column With A Custom Field To Wordpress Admin Post Listing
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
/////////////////////////////////////////////////////////// | |
//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