Last active
December 21, 2015 14:49
-
-
Save jim912/6322607 to your computer and use it in GitHub Desktop.
こっちの方が簡潔
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
function add_thumbnail_column( $columns ) { | |
$post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post'; | |
if ( post_type_supports( $post_type, 'thumbnail' ) ) { | |
$columns['thumbnail'] = __( 'Featured Images' ); | |
} | |
return $columns; | |
} | |
function display_thumbnail_column( $column_name, $post_id ) { | |
if ( $column_name == 'thumbnail' ) { | |
if ( has_post_thumbnail( $post_id ) ) { | |
echo get_the_post_thumbnail( $post_id, array( 50, 50 ) ); | |
} else { | |
_e( 'none' ); | |
} | |
} | |
} | |
add_filter( 'manage_posts_columns', 'add_thumbnail_column' ); | |
add_filter( 'manage_pages_columns', 'add_thumbnail_column' ); | |
add_action( 'manage_posts_custom_column', 'display_thumbnail_column', 10, 2 ); | |
add_action( 'manage_pages_custom_column', 'display_thumbnail_column', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment