Forked from samuelguebo/thumbnail-in-post columns-dashbord.php
Created
October 19, 2016 21:44
-
-
Save niladam/8f5ef9fb8014025cad2e4c3e050cb58b 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
## Add thumbnail to post columns in Dashboard | |
``` | |
add_image_size( 'admin-list-thumb', 80, 80, false ); | |
// add featured thumbnail to admin post columns | |
function wpcs_add_thumbnail_columns( $columns ) { | |
$columns = array( | |
'cb' => '<input type="checkbox" />', | |
'featured_thumb' => 'Thumbnail', | |
'title' => 'Title', | |
'author' => 'Author', | |
'categories' => 'Categories', | |
'tags' => 'Tags', | |
'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>', | |
'date' => 'Date' | |
); | |
return $columns; | |
} | |
function wpcs_add_thumbnail_columns_data( $column, $post_id ) { | |
switch ( $column ) { | |
case 'featured_thumb': | |
echo '<a href="' . get_edit_post_link() . '">'; | |
echo the_post_thumbnail( 'admin-list-thumb' ); | |
echo '</a>'; | |
break; | |
} | |
} | |
if ( function_exists( 'add_theme_support' ) ) { | |
add_filter( 'manage_posts_columns' , 'wpcs_add_thumbnail_columns' ); | |
add_action( 'manage_posts_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 ); | |
add_filter( 'manage_pages_columns' , 'wpcs_add_thumbnail_columns' ); | |
add_action( 'manage_pages_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment