How to Display post attachment count in admin column in WordPress

Sometimes you have a post with multiple attachments and it would be nice to see a count of the total media attached to a post. To see this you only need add this snippet to the functions.php

 

add_filter('manage_posts_columns', 'posts_columns_attachment_count', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns_attachment_count', 5, 2);
function posts_columns_attachment_count($defaults){
    $defaults['wps_post_attachments'] = __('Attached');
    return $defaults;
}
function 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;}
    }
}

 

167 responses to “How to Display post attachment count in admin column in WordPress

  1. Wholesale CBD

    I will right away grab your rss feed as I can’t find your e-mail subscription link or newsletter service. Do you’ve any? Kindly let me know so that I could subscribe. Thanks.

  2. more information

    I don’t even know how I finished up right here, but I believed this post used tobe great. I do not know who you are however definitely you are going to a famous blogger in the event youare not already 😉 Cheers!My blog post – belly fat supplements

  3. air cooler fan malaysia

    An interesting discussion is definitely worth comment. I do think that you should write more about this topic, it may not be a taboo subject but typically people don’t speak about these topics. To the next! Many thanks!!

  4. glavnoe.ua

    Wow that was odd. I just wrote an very long comment but after I clicked submit my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say great blog!

  5. glavnoe.ua

    Thank you for some other wonderful article. Where else could anyone get that type of information in such a perfect approach of writing? I’ve a presentation subsequent week, and I’m at the search for such information.

  6. https://www.nebraskahistory.org

    สาวกผี สาวกหงส์ สาวกสิงห์ สาวกเรือ สาวกไก่ สาวกหมาจิ้งจอก ไม่ว่าคุณจะเป็นสาวกไหนก็ตาม UFABET ขอเป็นส่วนหนึ่งในการแปลงสิ่งที่คุณชื่นชอบเป็นรายได้ ด้วยการชูคาสิโนมาไว้ให้ท่านแทงบอลออนไลน์ได้อย่างไม่ยากเย็นกันเลยขอรับ

  7. for more details

    สาวกผี สาวกหงส์ สาวกสิงห์ สาวกเรือ สาวกไก่ สาวกจิ้งจอก ไม่ว่าคุณจะเป็นสาวกไหนก็ตาม UFABET ขอเป็นส่วนหนึ่งสำหรับการเปลี่ยนสิ่งที่คุณชื่นชอบเป็นรายได้ ด้วยการชูคาสิโนมาไว้ให้แก่ท่านพนันบอลออนไลน์ได้ไม่ยากกันเลยขอรับ

  8. defi robo-advisor

    A fascinating discussion is definitely worth comment. There’s no doubt that that you should publish more about this issue, it might not be a taboo subject but typically folks don’t discuss these topics. To the next! Best wishes!!

  9. view

    I blog often and I seriously appreciate your information. The article has truly peaked my interest. I will take a note of your blog and keep checking for new information about once per week. I subscribed to your Feed too.

  10. marvoy.ie

    Hey are using WordPress for your blog platform? I’m new to the blog world butI’m trying to get started and create my own. Doyou need any coding expertise to make your own blog? Anyhelp would be greatly appreciated!

  11. Find Out More

    Daniella is another good option for tourists, offering both short and long term scooter letting with a lot of Scoopy stock, which is great for beginners. The team are responsive on Facebook, but often sell out fast during peak season due to the competitive monthly pricing. Note: I’ve tried a couple of Click 125i’s from Daniella, Both had 45k+ miles and felt/sounded a little rough around the edges.

  12. Helpful Site

    Hi there! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche.Your blog provided us valuable information to workon. You have done a wonderful job!

  13. internal linking of sides

    An interesting discussion is definitely worth comment. I do believe that you should write more about this topic, it may not be a taboo subject but generally folks don’t discuss these subjects. To the next! Many thanks!!

Deja una respuesta

Tu dirección de correo electrónico no será publicada.

Rúa Pilar Miró n 6 Santiago de Compostela

Jersey St , Manchester, Greater Manchester M4 6JG, GB

T. 609 538 171 - 634 59 34 43

info@teslatechnologies.com