Mika MAtikainen

Apr 15, 2020 · 4 min read

Wondering How Many Images an Author Has Attached to a Post?


add_filter('manage_posts_columns', 'wpsc_posts_columns_attachment_count', 5);
add_action('manage_posts_custom_column', 'wpsc_posts_custom_columns_attachment_count', 5, 2);
function wpsc_posts_columns_attachment_count($defaults){
$defaults['wps_post_attachments'] = __('Attached');
return $defaults;
}
function wpsc_posts_custom_columns_attachment_count($column_name, $id){
if($column_name === 'wps_post_attachments'){
$attachments = get_children(array('post_parent'=>$id));
$count = count($attachments);
if($count !=0){echo $count;}
}
}        

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Share This