I don't use WordPress very often... I hope this makes some sense :-)

Is there a way to sort media files into categories? I want to give some order to the media that are being uploaded to the website, and 'attaching' media to a Post is not cutting it :-)

After a quick search, I found these two plugins. Does anyone have any experience with them? Would anyone recommend another route?

Can I add a Category Metabox to attachment?


Both plugins would add the functionality that I'm after. Perhaps the only grievance is that media 'tagging' at upload time doesn't work with the 'browser uploader'...

  • great question... One of the key things which I have been trying to figure out is not only how to attach files to tags AND categories but I am looking for a way to be able to automatically assign uploads for posts within specific post types to a specific category. I wonder why this option does not exist by default... Commented Sep 20, 2010 at 14:10
  • 1
    aei: I made the first plugin you've listed above, I've actually just added a fix to the browser uploading of the WOS Media Categories Plugin now, you can download the latest version of the plugin via this link: suburbia.org.uk/page/projects.html#wos_media_categories Commented Nov 1, 2010 at 13:40

2 Answers 2


I've been using Media Tags plugin with much success - it was very useful for retrieving images belonging to certain page with specific tags with following code:

$results = get_attachments_by_media_tags(array("media_tags"=>"gallery", "post_parent" => $global_id, "order" => "ASC"));

Of course you can easily tag anything that sits in your media library (I wasn't even aware that you could tag something during upload time). As for tagging during upload with browser uploader - it might be too much too ask ;)


ok - just created a get_results query which return post/attachment ids that have a certain tag. Not ideal but does the job...

function get_attachments_by_tag( $tagid='5', $parentID=0 ){ 
    global $wpdb;

    $myrows = $wpdb->get_results( "SELECT object_id FROM $wpdb->term_taxonomy 
                    LEFT JOIN $wpdb->term_relationships ON $wpdb->term_taxonomy.term_taxonomy_id=$wpdb->term_relationships.term_taxonomy_id 
                    LEFT JOIN $wpdb->posts ON $wpdb->term_relationships.object_id=$wpdb->posts.id 
                    WHERE $wpdb->term_taxonomy.term_id = '".$tagid."' AND $wpdb->posts.post_parent = '".$parentID."' " );

    foreach ( $myrows as $item ) {
        $sc = get_object_vars($item);   
        $pmIDs[] = $sc['object_id'];

    return $pmIDs;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.