Created
September 9, 2021 01:42
-
-
Save taotiwordpress/62f5cfee5049f8ab916fce5503f5467c to your computer and use it in GitHub Desktop.
[show thumbnail in CPT] Show Custom Post Type thumbnail in admin column #CPT #admin
This file contains hidden or 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 custom_columns( $columns ) { | |
$columns = array( | |
'cb' => '<input type="checkbox" />', | |
'featured_image' => 'Image', | |
'title' => 'Title', | |
'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>', | |
'date' => 'Date' | |
); | |
return $columns; | |
} | |
add_filter('manage_people_posts_columns' , 'custom_columns'); | |
function custom_columns_data( $column, $post_id ) { | |
switch ( $column ) { | |
case 'featured_image': | |
the_post_thumbnail( 'thumbnail' ); | |
break; | |
} | |
} | |
add_action( 'manage_people_posts_custom_column' , 'custom_columns_data', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment