Skip to content

Instantly share code, notes, and snippets.

@taotiwordpress
Created September 9, 2021 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taotiwordpress/62f5cfee5049f8ab916fce5503f5467c to your computer and use it in GitHub Desktop.
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
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