掌握WordPress链接管理器

Finding a list of links on a website is not a rare thing. For example, a lot of blogs have their own blogroll to spread the word about their friends’ blogs, or other websites displayed in a carousel to highlight some links, whether internal or external.

在网站上找到链接列表并非罕见。 例如,许多博客都有自己的Blogroll,以传播有关朋友博客的信息,或在轮播中显示其他网站以突出显示内部或外部链接。

To create these lists, you can just add them in the HTML code and hardcode the links. The problem is that this method isn’t very practical: to modify, remove or add a link, you must modify the source code.

要创建这些列表,您只需将它们添加到HTML代码中,然后对链接进行硬编码。 问题在于该方法不是很实用:要修改,删除或添加链接,必须修改源代码。

That’s why the WordPress Links Manager exists.

这就是WordPress链接管理器存在的原因。

什么是WordPress链接管理器,为什么要使用它? (What Is the WordPress Links Manager and Why Use It?)

管理链接的有用工具 (A Useful Tool to Manage Links)

As its name suggests, the Links Manager allows you to manage a list of links, sorted by categories. These links are accessible from the administration panel so you can easily add a new one or modify and remove an existing one.

顾名思义,“链接管理器”允许您管理按类别排序的链接列表。 这些链接可从管理面板访问,因此您可以轻松添加新链接或修改和删除现有链接。

To display and use the links added in the Links Manager, we have several choices. By default, WordPress provides us a widget to add to a sidebar, which will display your links. But you can also build your own lists thanks to the dedicated API.

要显示和使用在“链接管理器”中添加的链接,我们有几种选择。 默认情况下,WordPress为我们提供了一个添加到侧边栏的小部件,它将显示您的链接。 但是,借助专用的API,您也可以构建自己的列表。

WordPress链接管理器在哪里? (Where Is the WordPress Links Manager?)

The Links Manager was provided by default in WordPress in earlier versions. However, it disappeared with version 3.5; since this release, you couldn’t find the Links Manager on a brand new WordPress installation. Moreover, if you used an earlier version than 3.5 and upgraded your installation, then the Links Manager was removed, unless you used it.

默认情况下,早期版本的WordPress中提供了链接管理器。 但是,它在3.5版中消失了。 从此版本开始,您将无法在全新的WordPress安装中找到链接管理器。 此外,如果您使用的版本低于3.5,并且升级了安装,则除非使用了Links Manager,否则将删除该链接管理器。

If you used an earlier version of WordPress than 3.5, and had links before the upgrade, then you should have the Link Manager. If you haven’t, you can find it by downloading the Links Manager plugin, which is the official way to retrieve the old tool. You can install it just as you would install any other plugin, or you can install it as a mu-plugin if you think that it should be a part of WordPress.

如果您使用的WordPress版本早于3.5,并且在升级之前具有链接,那么您应该拥有链接管理器。 如果没有,可以通过下载Links Manager插件找到它,这是检索旧工具的官方方法。 您可以像安装其他任何插件一样安装它,也可以将它作为mu插件安装,如果您认为它应该是WordPress的一部分。

Note that the plugin is a very short one: actually it is a one line plugin that only adds a filter to activate the Links Manager. That means you can activate the Links Manager by yourself by adding the following line in the functions.php file of your theme.

请注意,该插件是一个非常简短的插件:实际上,它是一个单行插件,仅添加了一个过滤器来激活链接管理器。 这意味着您可以通过在主题的functions.php文件中添加以下行来自行激活Links Manager。

add_filter('pre_option_link_manager_enabled', '__return_true');

This also means that if you develop themes for other users and want to use the Links Manager in these themes, you can activate it with this line. That way, your users won’t have to download a plugin to be able to correctly use your theme.

这也意味着,如果您为其他用户开发主题并希望在这些主题中使用链接管理器,则可以在此行中将其激活。 这样,您的用户将无需下载插件即可正确使用您的主题。

Whether present by default in your WordPress installation or activated with the plugin or the filter, the Links Manager can be found in the administration panel’s sidebar with its own section: “Links“.

无论是在WordPress安装中默认存在还是通过插件或过滤器激活,都可以在管理面板的侧栏中带有其自己的部分的“ 链接 ”中找到链接管理器。

添加新链接 (Adding a New Link)

By accessing the “Links” section, you arrive by default at your links list. Similar to your posts list, this list also provides an “Add new” button next to the page’s title. Hit this button to add a new link thanks to a complete form.

通过访问“ 链接 ”部分,默认情况下,您会到达链接列表。 与您的帖子列表类似,此列表还在页面标题旁边提供了“ 添加新内容 ”按钮。 点击此按钮可以添加新链接,这要归功于完整的表格。

This form contains a lot of different options. Depending on your use of the links you add, some of these options will be totally useless, but don’t worry: the only required field is the “Web Address” one in which you indicate the link’s URL. All the other fields are optional, so fill them out only if you will use them.

该表格包含许多不同的选项。 根据您对所添加链接的使用情况,其中一些选项将完全无用,但是请放心:唯一需要的字段是“ Web Address ”,您可以在其中指定链接的URL。 所有其他字段都是可选的,因此仅在使用它们时填写它们。

描述您的链接 (Describing Your Link)

Displaying links is a thing, but if you want to make these links useful, then you need to describe them. In the “Name” field, you can indicate a name for your link. The name should be short, but also descriptive: a link’s name should be viewed in the same light as a post’s title.

显示链接是一件很重要的事情,但是如果您想使这些链接有用,则需要对其进行描述。 在“ 名称 ”字段中,您可以为链接指定名称。 名称应简短,但也应具有描述性:链接名称应与帖子标题相同。

Below the “Web Address” field, you can find the “Description” field. In this field, you can really describe your link; you can indicate why you chose it, why you think it’s useful, or simply what it is.

在“ 网址 ”字段下方,您可以找到“ 说明 ”字段。 在此字段中,您可以真正描述您的链接; 您可以指出为什么选择它,为什么认为它有用或仅仅是它的用途。

For example, let’s create a link to SitePoint.

例如,让我们创建一个指向SitePoint的链接。

Adding a New Link

有关链接的更多详细信息 (More Details About Your Link)

You can choose to add more detail your link by indicating a relationship: if this link points to a specific person (for example, if the address is your friend’s personal webpage), then you can indicate the relationship you have with this person. There are several options, and you surely won’t use all of them, but you should know they exist if you ever need them.

您可以通过指示关系来选择添加更多详细信息:如果此链接指向特定的人(例如,如果地址是您朋友的个人网页),则可以表明您与该人的关系。 有几种选择,您肯定不会全部使用,但是如果您需要它们,应该知道它们的存在。

The “Link Relationship” section is where you fill in the rel HTML attribute of your link, once it is displayed. If you use this section, be sure that it is read by the script which displays your links!

一旦显示链接,“ 链接关系 ”部分即为您填充链接的rel HTML属性。 如果使用此部分,请确保显示链接的脚本已读取该部分!

The “Advanced” section can be useful to add some additional information about your links. The “Image Address” field excepts an image’s URL. For example, if you want to display your links in a carousel, this field is the best place to indicate the image illustrating the link.

高级 ”部分对添加有关链接的其他信息很有用。 “ 图片地址 ”字段,图片的URL除外。 例如,如果要在轮播中显示链接,则此字段是指示插图的最佳位置。

If your link points to a website using an RSS feed, you can indicate it in the “RSS Address” field. For example, your carousel can display a background image thanks to the previous field and add a small RSS button to indicate where your users can follow the website.

如果您的链接使用RSS feed指向网站,则可以在“ RSS地址 ”字段中进行指示。 例如,由于前一个字段,您的轮播可以显示背景图片,并添加一个小的RSS按钮以指示您的用户可以在哪里浏览该网站。

A big text area labeled “Notes” allows you to add anything you want about your link. It can be an information used (and eventually displayed) by your theme, or it can be a personal note to inform your future you why you added this link.

标有“ Notes ”的大文本区域使您可以添加有关链接的任何内容。 它可以是主题使用(并最终显示)的信息,也可以是个人笔记,以告知您将来添加此链接的原因。

If you want to rate your links, it is possible thanks to the last field of the “Advanced” section: a list which allows you to rate the link between 0 and 10.

如果您想对链接进行评分,则可以借助“ 高级 ”部分的最后一个字段:一个列表,该列表可让您在0到10之间对链接进行评分。

Finally, you can chose to open the link in a new tab, or not, by selecting the right option in the “Target” section. Note that, once again, be sure that the script you use to display your links correctly fills the target HTML attribute.

最后,您可以通过在“ 目标 ”部分中选择正确的选项,选择是否在新选项卡中打开链接。 请再次注意,确保用于显示链接的脚本正确填充了target HTML属性。

私人连结 (Private Links)

Right above the submitting button, you can find a checkbox labeled “Keep this link private“. As you can guess, this allows you to create links without publishing them, temporarily or not.

在“提交”按钮上方,您可以找到一个标记为“ 将此链接设为私有 ”的复选框。 可以猜到,这使您可以创建链接,而不必临时或不发布它们。

Private links can be published at any time by simply unchecking the box, and you can hide public links by checking the box when you edit the link information.

只需取消选中该复选框,即可随时发布专用链接,而在编辑链接信息时,也可以通过选中该复选框来隐藏公共链接。

Private links won’t be displayed by WordPress: the widget we will see below will simply ignore them and your visitors won’t be able to see them. They won’t even know that these links exist.

WordPress不会显示私人链接:我们将在下面看到的小部件将忽略它们,并且您的访客将无法看到它们。 他们甚至不知道这些链接存在。

Private links can be useful to simulate drafts: if you need more time to prepare the description of a link, but don’t want to delete all the information you have already typed, then private links are a good option.

专用链接对于模拟草稿很有用:如果您需要更多时间来准备链接的描述,但又不想删除已经输入的所有信息,那么专用链接是一个不错的选择。

整理链接 (Organizing Your Links)

After filling all the fields you want, you can add the link by simply hitting the “Add Link” button. But, there is a section we haven’t yet discovered: “Categories“.

填写完所需的所有字段后,您只需单击“ 添加链接 ”按钮即可添加链接 。 但是,有一个我们尚未发现的部分:“ Categories ”。

Contrary to your posts which will go into the “Unsorted” category if you don’t make your choice before submitting them, your links don’t need a category. If you don’t choose a category, then the link won’t be included in any category.

与您的帖子相反,如果您在提交之前没有做出选择,则这些帖子将进入“ 未排序 ”类别,您的链接不需要类别。 如果您不选择类别,则该链接将不包含在任何类别中。

However, if you use links in several places, organizing them can be a good idea. For example, a carousel will only display the links sorted in a “Carousel” category while a widget in your sidebar will display all the links in a “Sidebar” category.

但是,如果您在多个地方使用链接,将它们组织起来可能是一个好主意。 例如,轮播仅显示按“ 轮播 ”类别分类的链接,而侧边栏中的小部件将显示“ 侧栏 ”类别中的所有链接。

The links categories list is similar to the posts categories list, as you can select the category you want for your link by simply checking the right one, but you can also add a new category, thanks to the link below the list.

链接类别列表类似于帖子类别列表,因为您可以通过简单地选择正确的链接来选择想要的链接类别,但是由于列表下方的链接,您还可以添加新类别。

Note that you can select several categories and, if you have a lot of categories, you can filter the list by only displaying the most used categories.

请注意,您可以选择多个类别,如果有很多类别,则可以仅显示最常用的类别来过滤列表。

You can manage your links categories by accessing the “Link Categories” subsection of the “Links” section in the administration panel’s sidebar. This page lists your categories and allows you to add a description or modify their slug. A form allows you to add a new category directly with this information (contrary to the link we talked above, which only allows you to choose the name of the new category).

您可以通过访问管理面板侧边栏中“ 链接 ”部分的“ 链接类别 ”子部分来管理链接类别。 此页面列出了您的类别,并允许您添加描述或修改其条目。 表格允许您直接使用此信息添加新类别(与上面讨论的链接相反,该链接仅允许您选择新类别的名称)。

You can finally delete all your unused categories: they are easy to pinpoint thanks to the “Links” column which displays the number of links, using the corresponding category.

最后,您可以删除所有未使用的类别:由于“ 链接 ”列使用相应的类别显示了链接数,因此很容易找到它们。

编辑或删除链接 (Editing or Removing a Link)

As we said above, the links list is similar to the posts one, so you won’t be disoriented by the way you can edit or remove a link.

如上所述,链接列表与帖子列表类似,因此您不会因编辑或删除链接而迷失方向。

In fact, by hovering over a link’s row, you’ll see two links appear: “Edit” and “Delete“. By hitting “Delete“, a message prompt will be displayed, asking you to validate your choice. Be careful: there is no trash bin in the Links Manager so deleting a link is a definitive action.

实际上,通过将鼠标悬停在链接的行上,您会看到两个链接出现:“ Edit ”和“ Delete ”。 点击“ 删除 ”,将显示一条消息提示,要求您确认选择。 请注意:“链接管理器”中没有垃圾桶,因此删除链接是确定的动作。

Note that, as in the posts list, hitting the link’s name or the “Edit” link will have the same effect of redirecting you to the right page. This page is almost the same as the one where you can add a link. The difference is in the page’s title and in some buttons’ labels. Moreover, the form is prefilled with the current values you can modify.

请注意,就像在帖子列表中一样,单击链接名称或“ Edit ”链接将具有将您重定向到正确页面的相同效果。 该页面与您可以添加链接的页面几乎相同。 区别在于页面的标题和某些按钮的标签。 此外,表格中会预先填充您可以修改的当前值。

Finally, the links list can be filtered by categories, and checkboxes allow you to simultaneously delete several links.

最后,可以按类别过滤链接列表,并且可以使用复选框同时删除几个链接。

显示小部件的链接 (Displaying Links with the Widget)

If your theme allows you to customize a place like a sidebar or a footer with widgets, then you can easily display your links in this place, as WordPress provides a widget within its Links Manager.

如果您的主题允许您自定义带有小部件的侧边栏或页脚之类的位置,那么您可以轻松地在此位置显示您的链接,因为WordPress在其“链接管理器”中提供了一个小部件。

Like any other widget, to add the Links Manager widget, you must go into the “Widgets” subsection of the “Appearance” section of the administration panel. You’ll see here the list of available widgets where you will be able to find the “Links” one. Drag and drop the Links widget to wherever you want it to appear. This will open a menu that enables you to personalize the widget.

与其他任何窗口小部件一样,要添加“链接管理器”窗口小部件,您必须进入管理面板“ 外观 ”部分的“ 窗口小部件 ”子部分。 您将在此处看到可用小部件的列表,在这些小部件中可以找到“ 链接 ”。 将“链接”小部件拖放到您希望其出现的任何位置。 这将打开一个菜单,使您可以个性化窗口小部件。

From here, you can here the link category that you want to display (for example, the “Blogroll” category in a sidebar). If you don’t have a lot of links, or if you have not set any category because you use links in only one place, you can also choose to display all categories.

在这里,您可以在此处显示要显示的链接类别(例如,边栏中的“ Blogroll ”类别)。 如果没有很多链接,或者由于仅在一个位置使用链接而没有设置任何类别,则还可以选择显示所有类别。

Once you have chosen the category you wish to use, you can customize the display by itself, beginning with the way the links are sorted. You have four choices: sorting links by title, by rating, by ID, or displaying links in a random order.

选择了要使用的类别后,您可以自定义显示方式,从链接的排序方式开始。 您有四个选择:按标题,按等级,按ID对链接进行排序,或以随机顺序显示链接。

Below these two drop-down lists you can see four checkboxes. These will allow you to choose what you want to display: you can display the link’s name, its description, or even its rating and its associated image.

在这两个下拉列表的下方,您可以看到四个复选框。 这些将允许您选择要显示的内容:您可以显示链接的名称,其描述,甚至是其等级及其关联的图像。

Finally, you can limit the number of links to show. For example, assume that you have a category where you put some articles you find on the web. Displaying them in your sidebar can be a good idea to share your findings but, depending on the number of links you have in this category, the result can be very long. A solution can be to remove some links when you add new ones, but you can also keep all your links and display only the last five ones.

最后,您可以限制要显示的链接数。 例如,假设您有一个类别,其中放置了一些您在网络上找到的文章。 在侧边栏中显示它们可能是共享您的发现的一个好主意,但是,取决于您在此类别中链接的数量,结果可能会很长。 一种解决方案是在添加新链接时删除一些链接,但也可以保留所有链接并仅显示最后五个链接。

Don’t forget to validate your choices by hitting the “Save” button, and enjoy the result on your website!

不要忘记点击“ 保存 ”按钮来确认您的选择,并在您的网站上享受搜索结果!

结论 (In Conclusion)

Sharing links is a large part of what the Internet is, so doing it on your website is a good idea. Thanks to WordPress’ Links Manager, you can easily manage a list of links by adding, editing, removing and sorting them via the administration panel.

共享链接是Internet的很大一部分,因此在您的网站上进行共享是一个好主意。 借助WordPress的链接管理器,您可以通过管理面板添加,编辑,删除和排序链接来轻松管理链接列表。

Displaying our links with the widget is useful but, sometimes, we want to go further, to customize more things. A solution can be to write our own scripts to display our links.

显示我们与小部件的链接很有用,但有时我们想走得更远,以自定义更多内容。 一种解决方案是编写我们自己的脚本来显示我们的链接。

The good news is that it is possible thanks to a dedicated API that allows you to retrieve the links stored in your database, to display them the way you want, in the HTML elements you want. The Links Manager API will be the topic of a future article.

好消息是,有可能要归功于专用的API,该API允许您检索存储在数据库中的链接,并以所需HTML元素的方式显示所需的链接。 Links Manager API将成为未来文章的主题。

翻译自: https://www.sitepoint.com/wordpress-links-manager/

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值