Last active
May 6, 2020 15:23
-
-
Save ashokmhrj/abcb661c4e39bd53854b7df25f804b23 to your computer and use it in GitHub Desktop.
Showing feature image in admin post listing
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
/** | |
* 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