Created
June 12, 2018 02:11
-
-
Save ahmedmusawir/b8f83ca413127cbc700e30207d1019dc to your computer and use it in GitHub Desktop.
PLUGIN-DEV - ADD ADMIN COLUMNS
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
| function __construct() | |
| { | |
| add_filter( 'manage_posts_columns' , array( $this, 'add_views_column' ) ); | |
| add_action( 'manage_posts_custom_column' , array( $this, 'add_data_into_views_column' ), 5, 2 ); | |
| } | |
| public function add_views_column( $columns ) { | |
| $columns['post_views'] = __('Views'); | |
| $columns['featured_image'] = __('Featured Image'); | |
| return $columns; | |
| } | |
| function add_data_into_views_column( $column_name, $postID ) { | |
| // print_r($column_name); | |
| if ( $column_name === 'post_views' ) { | |
| echo get_post_meta( $postID, 'views', true ); | |
| } | |
| if ( $column_name === 'featured_image' ) { | |
| // Give the Post Thumbnail a class "alignleft". | |
| echo get_the_post_thumbnail( $postID, 'thumbnail', array( 'class' => 'alignleft' ) ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment