Show post attachment count in admin column


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



Copy this code and paste it in your HTML
  1. add_filter('manage_posts_columns', 'posts_columns_attachment_count', 5);
  2. add_action('manage_posts_custom_column', 'posts_custom_columns_attachment_count', 5, 2);
  3. function posts_columns_attachment_count($defaults){
  4. $defaults['wps_post_attachments'] = __('Att');
  5. return $defaults;
  6. }
  7. function posts_custom_columns_attachment_count($column_name, $id){
  8. if($column_name === 'wps_post_attachments'){
  9. $attachments = get_children(array('post_parent'=>$id));
  10. $count = count($attachments);
  11. if($count !=0){echo $count;}
  12. }
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.