Created
July 13, 2015 15:55
-
-
Save ronalfy/df82bd6814927e7e66ae to your computer and use it in GitHub Desktop.
WordPress Featured Images in Post List - Post Types
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
<?php | |
//Run in init action | |
//Replace apartments with your post type name | |
//Must use PHP >= 5.3 | |
add_filter( 'manage_apartments_posts_columns', function( $columns ) { | |
$columns['apt_thumb'] = __('Thumb'); | |
return $columns; | |
} ); | |
add_action( 'manage_apartments_posts_custom_column', function( $column_name, $post_id ) { | |
if( $column_name == 'apt_thumb' ) { | |
if ( has_post_thumbnail( $post_id ) ) { | |
echo get_the_post_thumbnail( $post_id, 'thumbnail' ); | |
} | |
} | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment