When you query attachments
, you have to take care about the post_status
argument that have a different meaning than for other post types. Attachments have the status of inherit
which means that there status should be the same as their parent post (ie the post from where they have been uploaded). This makes attachments associated to not published posts, and attachments that have been uploaded directly to the Media Library missing.
So to make you code work, you could replace
'post_status' => 'publish',
with
'post_status' => 'any',
Regarding the update_count_callback
parameter, it has to do with the count numbers that are displayed at some place in the admin. You can use this callback to compute this number yourself. So it has nothing to do with your issue.