Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ashlie-elizabeth-moore/42800b377a66e94759dd0c0b8e5940a7 to your computer and use it in GitHub Desktop.

Select an option

Save ashlie-elizabeth-moore/42800b377a66e94759dd0c0b8e5940a7 to your computer and use it in GitHub Desktop.
Wordpress Backend Tweaks: Control Admin Columns + Add Thumbnail FOR ALL POST TYPES [Archived]
//POST ADMIN COLUMNS --->
add_filter('manage_posts_columns' , 'df_custom_columns');
function df_custom_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'featured_image' => 'Image',
'title' => 'Title',
'categories' => 'Categories',
'tags' => 'Tags',
'date' => 'Date'
);
return $columns;
}
//**Post Admin Thumbnails
add_action( 'manage_posts_custom_column' , 'df_custom_columns_data', 10, 2 );
function df_custom_columns_data( $column, $post_id ) {
switch ( $column ) {
case 'featured_image':
$thumb = get_the_post_thumbnail_url( $post_id, 'thumbnail' );
echo ($thumb) ? '<img src="'.$thumb.'" width="150px" height="auto">' : '';
break;
}
}
// POST ADMIN COLUMNS <---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment