lolitaloco

DISPLAY POST THUMB ON EDIT POSTS SCREEN (WORDPRESS)

Apr 9th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. /* DISPLAY POST THUMB ON EDIT POSTS SCREEN */
  2. if(!function_exists('displayThumbsColumn') && function_exists('add_theme_support')) {
  3.     function addThumbsColumn($cols) {
  4.         $cols['thumbnail'] = __('Post thumbnail');
  5.         return $cols;
  6.     }
  7. function displayThumbsColumn($column_name, $post_id) {
  8.     switch($column_name) {
  9.         case 'thumbnail' :
  10.             $thumb = get_post_meta($post_id, '_thumbnail_id', true);
  11.             if (empty($thumb)) break;
  12.             else echo wp_get_attachment_image($thumb, 'thumbnail');
  13.             break;
  14.         default :
  15.             break;
  16.         }
  17.     }
  18. // display on posts edit screen
  19. add_filter( 'manage_posts_columns', 'addThumbsColumn' );
  20. add_action( 'manage_posts_custom_column', 'displayThumbsColumn', 10, 2 );
  21. // display on custom post type (named "my_custom_post_type" for clarity...) edit screen
  22. add_filter( 'manage_edit-my_custom_post_type_columns', 'addThumbsColumn' );
  23. add_action( 'manage_my_custom_post_type_posts_custom_column', 'displayThumbsColumn', 10, 2 );
  24. }
Add Comment
Please, Sign In to add comment