Created
October 10, 2013 11:28
-
-
Save mkwebworker/6916894 to your computer and use it in GitHub Desktop.
Add a custom column with post thumbnail to the post overview
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
/* Add the post thumbnail to admin panel - marcokuemmel.de*/ | |
function my_custom_column_content($column) | |
{ | |
if ($column == 'featuredimage') | |
{ | |
global $post; | |
echo (has_post_thumbnail($post->ID)) ? the_post_thumbnail(array(80,80)) : '<p>kein Bild festgelegt</p>' ; | |
} | |
} | |
// for cpt use manage_{$post_type}_posts_custom_column | |
add_action('manage_posts_custom_column', 'my_custom_column_content'); | |
function my_custom_column_setup($columns) | |
{ | |
return array_merge($columns, array('featuredimage'=>'Artikelbild')); | |
} | |
// replace posts with name of the post type to add the column on other post types | |
add_filter('manage_edit-posts_columns', 'my_custom_column_setup'); | |
function my_admin_head() | |
{ | |
echo '<style type="text/css"> body.wp-admin table.wp-list-table .column-featuredimage { width:10%; } </style>'; | |
} | |
add_action('admin_head', 'my_admin_head'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment