Skip to content

Instantly share code, notes, and snippets.

@ashokmhrj
Last active May 6, 2020 15:23
Show Gist options
  • Save ashokmhrj/abcb661c4e39bd53854b7df25f804b23 to your computer and use it in GitHub Desktop.
Save ashokmhrj/abcb661c4e39bd53854b7df25f804b23 to your computer and use it in GitHub Desktop.
Showing feature image in admin post listing
/**
* WordPress
* Showing feature image in admin post listing
*/
add_filter('manage_posts_columns' , 'ask_custom_columns');
/*add_filter('manage_{post-type-slug}_posts_columns' , 'ask_custom_columns');*/
function ask_custom_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'featured_image' => 'Feature Image',
'title' => 'Title',
'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>',
'date' => 'Date'
);
return $columns;
}
add_action( 'manage_posts_custom_column' , 'ask_custom_columns_data', 10, 2 );
/*add_filter('manage_{post-type-slug}_posts_custom_column' , 'ask_custom_columns_data',10,2);*/
function ask_custom_columns_data( $column, $post_id ) {
switch ( $column ) {
case 'featured_image':
the_post_thumbnail( 'thumbnail' );
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment