DISPLAY POST VIEWS WITHIN ADMIN POST COLUMNS


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. add_filter('manage_posts_columns', 'posts_column_views');
  2. add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
  3. function posts_column_views($defaults){
  4. $defaults['post_views'] = __('Views');
  5. return $defaults;
  6. }
  7. function posts_custom_column_views($column_name, $id){
  8. if($column_name === 'post_views'){
  9. echo getPostViews(get_the_ID());
  10. }
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.