如何组织您的WordPress Blogroll链接?

Many WordPress Themes that are released usually come with the default blogroll codes. With that code you have no control over the organization of the blogroll links in your sidebar. By default it is all organized alphabetically, but in this article we will show you how you can control how your blogroll is displayed.

许多发布的WordPress主题通常带有默认的Blogroll代码。 使用该代码,您无法控制边栏中的Blogroll链接的组织。 默认情况下,它们都是按字母顺序组织的,但是在本文中,我们将向您展示如何控制Blogroll的显示方式。

Update: Please note that Link Manager was sort of removed in WordPress 3.5. We recommend that you use WordPress menus because they are much more flexible. See details in this article.

更新:请注意,链接管理器已在WordPress 3.5中删除。 我们建议您使用WordPress菜单,因为它们更加灵活。 请参阅本文的详细信息。

The default code looks like the one below:

默认代码如下所示:

<?php wp_list_bookmarks(); ?>

<?php wp_list_bookmarks(); ?>

The code above will show all links and categorizes them alphabetically. First it will organize the categories you place the links in, and then it will organize the links within the categories. But what if you just want to display a specific category of links.

上面的代码将显示所有链接,并按字母顺序对它们进行分类。 首先,它将组织您放置链接的类别,然后将组织类别中的链接。 但是,如果您只想显示特定类别的链接,该怎么办。

First you need to make a category in your Links section of the WordPress Admin Panel. Then add links to it. Once you have done that find out the category id.

首先,您需要在WordPress管理面板的“链接”部分中创建一个类别。 然后添加链接。 完成后,找出类别ID。

<?php wp_list_bookmarks('title_li=&category=2'); ?>

<?php wp_list_bookmarks('title_li =&category = 2'); ?>

Change the number 2 to the category id, and you can now sort out your links at different areas of the template if you so desire. Now you can take the code above to the next step where you can add more parameters to actually organize the way links are organized.

将数字2更改为类别ID,现在您可以根据需要在模板的不同区域整理链接。 现在,您可以将上面的代码用于下一步,可以在其中添加更多参数来实际组织链接的组织方式。

There is a parameter called “Orderby” which gives the following options:

有一个名为“ Orderby”的参数,该参数提供以下选项:

  • ‘id’

    'ID'
  • ‘url’

    网址
  • ‘name’

    '名称'
  • ‘target’

    '目标'
  • ‘description’

    '描述'
  • ‘owner’ – User who added bookmark through bookmarks Manager.

    “所有者” –通过书签管理器添加书签的用户。
  • ‘rating’

    '评分'
  • ‘updated’

    '更新'
  • ‘rel’ – bookmark relationship (XFN).

    “ rel” –书签关系(XFN)。
  • ‘notes’

    '笔记'
  • ‘rss’

    'rss'
  • ‘length’ – The length of the bookmark name, shortest to longest.

    'length'-书签名称的长度,最短到最长。
  • ‘rand’ – Display bookmarks in random order.

    'rand'–以随机顺序显示书签。

So now your code will look like:

所以现在您的代码将如下所示:

<?php wp_list_bookmarks('title_li=&category=2&orderby=id'); ?>

<?php wp_list_bookmarks('title_li =&category = 2&orderby = id'); ?>

In the above code you are telling WordPress to pull links from category 2, arrange them in list format, and to display them in the order which comes first. So link id=1 will be shown first. WordPress by default shows ascending. But you can change the order by making the following changes:

在上面的代码中,您告诉WordPress从类别2中提取链接,并以列表格式对其进行排列,并按先后顺序显示它们。 因此,链接ID = 1将首先显示。 默认情况下,WordPress显示升序。 但是您可以通过以下更改来更改顺序:

<?php wp_list_bookmarks('title_li=&category=2&orderby=id&order=DESC'); ?>

<?php wp_list_bookmarks('title_li =&category = 2&orderby = id&order = DESC'); ?>

Now you are telling WordPress to show the links in the descending order. There are multiple other ways you can organize your blogroll links in WordPress. Please refer to the WordPress Codex for more instructions.

现在,您要告诉WordPress以降序显示链接。 您可以通过多种其他方式在WordPress中组织Blogroll链接。 请参考WordPress Codex了解更多说明。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-organize-your-wordpress-blogroll-links/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值