Created
June 15, 2022 20:08
-
-
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]
This file contains hidden or 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
| //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