How to Assign Medias to Tags and Categories

Some WordPress users often complained, if the media library gets tags or category, it would be easier to manage the media files, for examples, images. Yes, media system in WordPress has come a long way in the last years, however, it is not that user-friendly, and it should be better and easier to use.

As a saying goes, where there is problem, there are solutions, it is only a time problem. With that problem in mind, users figure out solutions recently. Here, we will walk through two easy ways to solve this problem.

Two methods: Here, we find two easy ways to assign media files: a plug-in solution and a non-plugin solution. For those who prefer non-plugin solutions, the latter one is just offered to them.

Method One: Use Enhanced Media Library Plugin

Plugin solutions always come with an easy way. This Enhanced Media Library Plugin in no exception. You can follow the link to see the details about this plugin. It is good, though it does not work with WordPress 3.9.

Why we recommend this plugin

For those who need to bulk upload images to site, or who already have lots of images in the library, this plugin allows them to move images into categories in bulk, for example, move 20 travel photos into a “Travel” category and then choosing 30 flower photos and moving them into a “flower” category.

With the other plugins, you may need to click Edit and then you can add images to corresponding categories one by one.

This plugin lets you use your existing categories and/or tags, or you can easily create your own that will only be available for media, the newly created categories will be aligned in Media category at lower place.

How to use it

There are couples of ways to assign your media to a category, here we will go over two simples ways to do that.

1. Assigning to Categories (or Tags) via the Uploader

Generally, we upload an image or images when we want to insert them to a post. With this plugin installed, you will see a Media category section on the right-hand side of the uploader/library for categories.

When you click to edit the image, you will see a similar section as well.

2. Via the Media Library List

If you have already upload many images before using this plugin, you may need to put images into more than one category (or change their categories), then you can go to the Media Library. (Media > Library)

When you hover over an image, you’ll now see options to assign the image to the categories you have set up.

If you click multiple images, you can then go to the drop-down at the top to the left of the Toggle Bulk button, choose your category, and then click Toggle Bulk, the images will be moved into a category.

Note: Since this plug-in may not works with some free WordPress themes, in your theme, some functions my not available, for example, the Toggle Bulk.

Code for Functions File

This is also very easy while not so powerful as the plugin method. By adding the code below to the function.php, you will see your images can be assign to categories and tags. And just like the steps talked above (Via the Media Library List), you can move images to categories, but you need to do that one by one.

// add categories for attachments

function add_categories_for_attachments() {

register_taxonomy_for_object_type( ‘category’, ‘attachment’ );


add_action( ‘init’ , ‘add_categories_for_attachments’ );

// add tags for attachments

function add_tags_for_attachments() {

register_taxonomy_for_object_type( ‘post_tag’, ‘attachment’ );


add_action( ‘init’ , ‘add_tags_for_attachments’ );

In the end
By assigning media files to tags or categories, managing the file will be much easier. Meanwhile, like tags and categories of posts, this assignment can also help increase your posts’ exposure in Google, Yahoo, etc.

About the author: Magee