如何将类别和标签添加到WordPress媒体库

Recently, one of our readers asked if it was possible to add categories and tags to images in WordPress media library. Adding categories and tags to images in media library can help you easily sort and locate images in WordPress. In this article, we will show you how to add categories and tags to WordPress media library.

最近,一位读者询问是否可以在WordPress媒体库中向图像添加类别和标签。 向媒体库中的图像添加类别和标签可以帮助您轻松地在WordPress中对图像进行排序和定位。 在本文中,我们将向您展示如何向WordPress媒体库添加类别和标签。

Category and tags for WordPress media library
为什么要向WordPress媒体库中的图像添加类别和标签? (Why Add Categories and Tags to Images in WordPress Media Library?)

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

WordPress带有称为分类法的功能,该功能使您可以将帖子分类为类别和标签 ,甚至可以创建自己的自定义分类法

The default category and tags taxonomies are available for posts only. However, taxonomies can be added to any WordPress post type like pages, attachments, or any custom post type you may be using on your blog.

默认类别和标签分类法仅适用于帖子。 但是,可以将分类法添加到任何WordPress帖子类型,例如页面, 附件或您可能在博客上使用的任何自定义帖子类型

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

将图像添加到WordPress帖子或页面时,它会作为附件存储在WordPress媒体库中。 附件是职位类型,这意味着它也可以具有自己的分类法。

Adding categories and tags to your WordPress images can help you find and sort images more easily.

将类别和标签添加到WordPress图像可以帮助您更轻松地查找和排序图像。

方法1:使用媒体库类别在WordPress中添加类别图像 (Method 1: Add Categories Images in WordPress with Media Library Categories)

First thing you need to do is install and activate the Attachment Taxonomies plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活附件分类法插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Media Library Categories plugin work out of the box and there are no settings for you to configure. Simply go to Media » Library and click on the list view button at the top.

Media Library Categories插件可以直接使用,没有可供您配置的设置。 只需转到媒体»库 ,然后单击顶部的列表视图按钮。

Switch to list view and click on edit link below any image

This will open media library in the list view. Click on the ‘Edit’ link below any image and WordPress will take you to edit image page.

这将在列表视图中打开媒体库。 单击任何图像下方的“编辑”链接,WordPress将带您编辑图像页面。

You will notice the new category meta box in the right hand column on the screen.

您会在屏幕的右列中看到新的类别元框。

Add category and tags to your image

Click on add new category link to add a new category. You can also create sub-categories. See our guide on how to add categories and subcategories in WordPress to learn more about hierarchical taxonomies.

单击添加新类别链接以添加新类别。 您还可以创建子类别。 请参阅有关如何在WordPress中添加类别和子类别的指南,以了解有关分层分类法的更多信息。

Once you are done, simply click on the update button to save your changes.

完成后,只需单击更新按钮以保存您的更改。

In order to display images or media filed under a category, you need to use the built-in WordPress gallery shortcode with extra category parameter.

为了显示类别下的图像或媒体,您需要使用带有额外类别参数的内置WordPress画廊简码。

[gallery category="14"]

[gallery category="14"]

Replace 14 with the ID of category you want to fetch your images from. See our guide on how to find category ID in WordPress.

将14替换为您要从中获取图像的类别ID。 请参阅我们的指南,了解如何在WordPress中查找类别ID

方法2:使用Envira Gallery将标签添加到WordPress中的图像 (Method 2: Adding Tags to Images in WordPress Using Envira Gallery)

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是市场上最好的WordPress照片画廊插件 。 它允许您在WordPress中创建美观且适合移动设备的图像库。

Envira Gallery comes with a Tags Addon which allows you to add tags to images you add to galleries.

Envira Gallery带有“ 标签插件” ,可让您向添加到画廊的图像添加标签。

It is a paid plugin, and you will need at least a Silver license to access the tags addon. WPBeginner users can use this Envira Gallery Coupon to get 25% Off.

这是一个付费插件,您至少需要白银许可证才能访问标签插件。 WPBeginner用户可以使用此Envira Gallery优惠券获得25%的折扣。

First thing you need to do is install and activate the Envira Gallery plugin.

您需要做的第一件事是安装并激活Envira Gallery插件。

For more details, see our step by step guide on how to install a WordPress plugin.

有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, you need to visit Envira Gallery » Settings page to enter your license key. You can get the key from your account on Envira Gallery website.

激活后,您需要访问Envira Gallery»设置页面以输入许可证密钥。 您可以从Envira Gallery网站上的帐户中获取密钥。

Envira Gallery license

After verification, you need to visit Envira Gallery » Addons page. Locate or search for the Tags Addon and then click Install. Once installed, click on the activate addon button.

验证后,您需要访问Envira Gallery»插件页面。 找到或搜索“标签插件”,然后单击“安装”。 安装完成后,单击激活加载项按钮。

Envira Gallery tags addon

After activating the Tags Addon, you can create a new Gallery or edit an existing gallery. If you are new to Envira Gallery, then check out our guide on how to easily create responsive WordPress image galleries with Envira.

激活标签插件后,您可以创建一个新的库或编辑现有库。 如果您是Envira Gallery的新手,请查看我们的指南, 了解如何使用Envira轻松创建响应式WordPress图像画廊

After adding an image to your gallery, you can click on the pencil icon on the image to edit its meta data.

将图像添加到图库后,您可以单击图像上的铅笔图标以编辑其元数据。

Envira will open the image in a popup with the meta data fields in the right hand column. At the bottom of the meta data fields, you will notice the tags field.

Envira将在弹出窗口中打开图像,并在右栏中显示元数据字段。 在元数据字段的底部,您会注意到标签字段。

Envira add tags

Go ahead and type your tags.

继续输入您的标签。

If you are adding more than one tag, then separate each tag with a comma. Don’t forget to click on the save metadata button to store your changes.

如果要添加多个标签,请用逗号分隔每个标签。 不要忘记单击“保存元数据”按钮来存储您的更改。

Repeat the process to add tags to other images in your gallery.

重复此过程以将标签添加到图库中的其他图像。

You can also display tags in your gallery. Simply click on the tags tab when editing your gallery and check the box next to Enable Tag Filtering option.

您也可以在图库中显示标签。 在编辑图库时,只需单击标签选项卡,然后选中启用标签过滤选项旁边的框。

Enabling tag filtering for a gallery created with Envira Gallery

You can choose which tags to be displayed or excluded, sort tags alphabetically or manually, and other settings as well.

您可以选择要显示或排除的标签,也可以按字母或手动对标签进行排序,以及其他设置。

Once you are done, click on publish or save button to save your gallery.

完成后,单击“发布”或“保存”按钮以保存您的画廊。

An image gallery with tags

That’s all, we hope this article helped you learn how to add categories and tags to WordPress media library. You may also want to see our guide on how to find royalty free images for your WordPress blog posts.

仅此而已,我们希望本文能帮助您学习如何向WordPress媒体库添加类别和标签。 您可能还想看看我们的指南, 指南如何为您的WordPress博客文章找到免版税图片

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.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-add-categories-and-tags-to-wordpress-media-library/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值