Photo by picjumbo.com from Pexels: https://www.pexels.com/photo/person-using-laptop-computer-during-daytime-196655/

How To Assign Categories To WordPress Media Library Files?

Enabling categories over WordPress media files lets you easily group and find the images. Just like posts, you can enable the category taxonomy in your WordPress admin area dashboard’s ‘Media’ section.

To do so, simply navigate to your admin area Plugins -> Add New page to search and install the Media Library Categories plugin on your website. Upon activation, the plugin will add a categories section on Media -> Categories page.

From this page, you would be able to create and manage categories. The categories could be either assigned while uploading the image or from the Dashboard -> Media page. You can also browse images by their category and perform bulk editing actions from this page using the drop-down option.

Apart from enabling you to add, remove, edit categories, change the category of multiple photos at once, and browse images by their category. The plugin also lets you display photos from a selective category by using a shortcode.

How To Display Photo Galleries By Category?

For displaying photos from a category in a gallery format you simply need to add the ‘category‘ attribute to the shortcode and then use it on any post or page just like any other shortcode.

The value handed to the ‘category‘ attribute can be either the category slug such as:

[gallery category="my-category-slug"]

Or the term_id, such as:

[gallery category="14"]

When you only want to display attachments uploaded to the page and filtered by category then use the ‘id‘ in combination with the ‘category‘ attribute:

[gallery category="my-category-slug" id="123"]

Or leave the ID empty for the current page/post:

[gallery category="my-category-slug" id=""]

In the given example, the slug is used, but as you can see the term_id can also be used.

You should also know that the WordPress Media Library uses the same categories as WordPress does in posts. Still, if you want you can use separate categories as a custom taxonomy from Settings -> Media page or by clicking on the settings quick link on the plugins overview page.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.