Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

How to Add Categories and Tags to WordPress Media Library

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Do you want to add categories and tags to images in your WordPress media library?

Adding tags and categories can help you organize images in a way that makes sense to you. This can make it easier to find images when you need them.

In this article, we will show you how to easily add categories and tags to the WordPress media library.

Add categories and tags to WordPress media library

Why Add Categories and Tags to Images in WordPress Media Library?

WordPress comes with a feature called taxonomies that allows you to sort your posts into categories and tags or even create your own custom taxonomies.

However, the default category and tag taxonomies are only available for posts. This means that these taxonomies can be added to any WordPress post type, including pages, attachments, or any custom post type you may be using on your blog.

When you add an image to your WordPress posts or pages, it is stored in the WordPress media library as an attachment. This means that it is a post type and can have its own taxonomies as well.

Adding categories and tags to your WordPress images can help you find and sort images easily. Instead of looking through your entire image library, you can just search by category or tag.

Plus, it can also improve your image SEO and help your WordPress site rank higher.

Having said that, let’s see how to easily add categories and tags to images in the WordPress media library. We will cover two methods, and you can use the quick links below to jump to the one you want to use:

Method 1: Add Categories to Images in WordPress Media Library

If you want to add categories to your images in the WordPress media library, then you can use this method.

First, you need to install and activate the Media Library Categories plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

This plugin works out of the box, and there are no settings for you to configure. Upon activation, the plugin will simply add a Categories tab under the Media menu tab in the WordPress dashboard.

Now, to add new categories for your images, head over to the Media » Categories tab from the WordPress admin sidebar.

Here, you’ll notice that all the categories that you have been using for your posts are displayed in the right column.

You can use these categories for your images. However, if you want to create a new one, then simply type a category name and slug in the ‘Add New Category’ section.

Create and add categories for images

Once you’re done, click the ‘Add New Category’ button to store your settings.

Next, visit the Media » Library page from the admin area and click on the ‘Edit’ link under any image where you want to add a category.

Choose an image to edit

This will open the image of your choice in the ‘Edit Media’ page, where you can easily select a category for it from the ‘Categories’ section in the right column.

Once you are done, don’t forget to click the ‘Update’ button to save your settings.

Add images category

If you want, you can also create sub-categories for the images. For more information, see our guide on how to add categories and subcategories.

Once you’ve added the categories for all the images, you can easily sort them on the ‘Library’ page. To do this, simply select a category of your choice from the ‘View all categories’ dropdown menu and click the ‘Filter’ button.

The WordPress media library will then only display images that belong to that category.

Filter images by category

If you want to add tags to images in the media library and allow users to filter images by tag on the front end, then this method is for you.

Envira Gallery is the best WordPress photo gallery plugin in the market. It allows you to create beautiful and mobile-friendly image galleries in WordPress.

Envira Gallery comes with a Tags Addon, which lets you add tags to the images in your galleries.

First, you need to install and activate the Envira Gallery plugin. For more detailed instructions, see our beginner’s guide on how to install a WordPress plugin.

Note: Envira Gallery also has a free plan. However, you’ll need at least the Plus plan of the plugin to unlock the Tags addon.

Upon activation, visit the Envira Gallery » Settings page from the WordPress dashboard to enter your license key.

You can get the key from your account on the Envira Gallery website.

Add the Envira Gallery license key

After that, visit the Envira Gallery » Addons page from the WordPress dashboard and locate the ‘Tags Addon’.

Once you do that, simply click the ‘Install’ button to unlock the Tags feature.

Upon installation, you’ll also have to toggle the switch to activate the Tags addon.

Install the Tags addon

Next, you can create a new gallery for your WordPress blog or edit an existing one. For this tutorial, we will be creating a new gallery for your WordPress website.

To do this, visit the Envira Gallery » Add New page from the WordPress dashboard. Here, you can start by typing a name for your gallery.

After that, click the ‘Select Files from Other Sources’ button to start adding images from your media library.

To add images from the computer, click the ‘Select Files from Your Computer’ button.

Add media library images

Once you’ve added the images, scroll down to the ‘Currently in your Gallery’ section. From here, you’ll be able to configure the gallery layout, add a lightbox, create a mobile responsive gallery, and so much more.

For details, see our beginner’s guide on how to create an image gallery in WordPress.

To add tags, simply click on the pencil icon on an image.

Click the pencil icon to edit an image

This will open the ‘Edit Metadata’ prompt on the screen, where you can add a title, alt text, and caption for your image.

You can also add multiple tags for an image by separating them with a comma. Once you are done, don’t forget to click the ‘Save Metadata’ button to store your settings.

Add image tags

Just repeat the process to add tags to other images in your gallery.

Once you’ve done that, switch to the ‘Tags’ tab from the left column and check the ‘Enable Tag Filtering?’ box.

This will allow your users to filter all your gallery images using the tags.

Enable tag filtering

By default, Envira Gallery will create a filter for all the tags that you have added to your gallery.

However, if you want to include only specific tags for filtering, then you can also do that by typing those tags in the ‘Tags to include in Filtering’ option.

If you leave this section blank, then all the tags will be filtered. Next, you can also choose the tag position, enable/disable the ‘All’ tags feature, and sort tags according to your liking.

Once you are done, don’t forget to click the ‘Publish’ button at the top to save your changes.

Choose specific tags for filtering

You and users will now be able to use tags to filter images on your website.

Filtering by Tag in the Media Library

To filter images using tags in the WordPress dashboard, visit the Media » Envira Tags page from the admin sidebar.

Here, you will notice all the tags that you have created are listed on the left, and the number of images with that tag is listed in the ‘Item’ column.

To find the images that have a specific tag, simply click on the ‘Items’ number for that tag.

For example, if you want to find all the images that have the tag ‘architecture’, then you will have to click the ‘1’ number in the architecture tag row.

Tag filtering on WordPress dashboard

This will open all the images with that tag in the media library.

This way, you don’t have to search through all your images to find the ones you are looking for.

Tag filtering image results

Filtering by Tag on the Front End

With Envira Gallery, users visiting your website can also filter images based on their tags.

Keep in mind that this feature will only work if you have checked the ‘Enable Tag Filtering?’ box for the gallery settings.

To enable this feature, you will first have to add the gallery you created to your website. For this, open a page/post in the content editor and click the add block ‘+’ button.

Once the block menu opens up, add the Envira Gallery block to the page/post and then select the gallery you created from the dropdown menu in the block itself.

Add envira gallery block

Finally, click the ‘Update’ or ‘Publish’ button to store your settings.

Now, you can visit your WordPress site to view the image gallery, where you will notice tags for filtering at the top of the images.

Once a user clicks on a tag, only images with that specific tag will be displayed in the gallery.

Tags filter preview

Bonus: Prevent Image Theft in WordPress

As a photographer or designer, using categories and tags can help you organize and display your images on your WordPress site. However, you may be worried about other people stealing your images.

This is called image theft, which is the unauthorized use of your images on other websites.

It is a common problem for photographers and graphic designers because even though uncopyrighted image theft is unethical, it is not illegal. This means anyone can copy and sell your images as their own,

However, there are a few tricks that you can use to prevent image theft on your WordPress blog.

The first thing that you should do is disable right-click on your images. This will protect your copyright and prevent users from easily saving your images on their desktops.

You can also add a watermark to your images. This method is used by many stock photography websites and allows you to promote your images while protecting them from being stolen.

To create watermarks for your images, you will have to download the Watermark addon from Envira Gallery.

It is the easiest way to add watermarks without using any custom code. For details, see our tutorial on how to automatically add a watermark to images in WordPress.

Add watermark to image gallery

Some other steps that you can take to protect your images include registering your copyright, using a digital signature on images, and including hidden foreground layers.

To learn more tips on protecting your website from image theft, see our beginner’s guide on ways to prevent image theft in WordPress.

We hope this article helped you learn how to add categories and tags to the WordPress media library. You may also want to see our guide on how to find royalty-free images for your WordPress blog posts and our picks for the best WordPress slider plugins.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

8 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. SCOTTM says

    Mike- You need another line to your code:

    add_action(‘init’, ‘add_tags_to_attachments’);

  3. mike says

    Stop using plugins for these things. It’s only 2 lines of code you need:
    function add_categories_to_attachments() {
    register_taxonomy_for_object_type('category', 'attachment');
    }
    add_action('init', 'add_categories_to_attachments');

    function add_tags_to_attachments() {
    register_taxonomy_for_object_type('post_tag', 'attachment');
    }

    • scott says

      Hi, your code added to my functions makes a category section which is awesome… but do you know how to have a sort by category drop down on the media sections?

    • per says

      this is pulling the variables from blog categories and tag, how to make a new list width categories and tags?

Leave a Reply to scott Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WPBeginner Assistant
How can I help you?

By chatting, you consent to this chat being stored according to our privacy policy and your email will be added to receive weekly WordPress tutorials from WPBeginner.