WordPress函数文档get_bookmarks()

获取所有的链接(可设置筛选条件) 描述 译文 该函数返回一个书签(收藏链接)数组。该模板标签允许用户直接查找书…

获取所有的链接(可设置筛选条件)

描述

译文

该函数返回一个书签(收藏链接)数组。该模板标签允许用户直接查找书签信息。

原文

This function returns an array of bookmarks found in the Administration > Links > Edit panel. This Template Tag allows the user to retrieve the bookmark information directly.

用法

 <?php get_bookmarks$args ); ?> 

Default Usage

By default, the usage gets:

  • All bookmarks ordered by name, ascending
  • Bookmarks marked as hidden are not returned.
  • The link_updated_f field (the update time in the form of a timestamp) is not returned.

参数

orderby 

(string) Value to sort bookmarks on. Defaults to ‘name’. Valid options:

  • ‘link_id’ – Before WordPress 3.2: ‘id’
  • ‘url’
  • ‘name’ – Default
  • ‘owner’ – User who added bookmark through bookmarks Manager.
  • ‘rating’
  • ‘visible’
  • ‘length’ – The length of the bookmark name, shortest to longest.
  • ‘rand’ – Display bookmarks in random order.

order 

(string) Sort order, ascending or descending for the orderby parameter. Valid values:

  • ASC – Default
  • DESC

limit 

(integer) Maximum number of bookmarks to display. Defaults to -1 (all bookmarks).

category 

(string) Comma separated list of bookmark category ID’s.

category_name 

(string) Category name of a category of bookmarks to retrieve. Overrides category parameter.

hide_invisible 

(boolean) TRUE causes only bookmarks with link_visible set to ‘Y’ to be retrieved.

  • 1 (True) – Default
  • 0 (False)

show_updated 

(boolean) TRUE causes an extra column called “link_category_f” to be inserted into the results, which contains the same value as “link_updated”, but in a unix timestamp format. Handy for using PHP date functions on this data.

  • 1 (True)
  • 0 (False) – Default

include 

(string) Comma separated list of numeric bookmark IDs to include in the output. For example, ‘include=1,3,6’ means to return or echo bookmark IDs 1, 3, and 6. If the include string is used, the category, category_name, and exclude parameters are ignored. Defaults to (all Bookmarks).

exclude 

(string) Comma separated list of numeric bookmark IDs to exclude. For example, ‘exclude=4,12’ means that bookmark IDs 4 and 12 will NOT be returned or echoed. Defaults to (exclude nothing).

search 

(string) Searches link_url, link_name or link_description like the search string. Defaults to .

返回值

(array) 

List of bookmark row objects. Each bookmark object may contain the following: ‘link_id’, ‘link_url’, ‘link_name’, ‘link_image’, ‘link_target’, ‘link_category’, ‘link_description’, ‘link_visible’, ‘link_owner’, ‘link_rating’, ‘link_updated’, ‘link_rel’, ‘link_notes’, ‘link_rss’

示例

– Create a link category named “Related Sites”
– Create a few links, adding them to the “Related Sites” category

You may use the following code in your templates to retrieve the links:

源文件

get_bookmarks() 函数的代码位于 wp-includes/bookmark.php.

相关

get_bookmark(),
get_bookmark_field(),
get_bookmarks(),
wp_list_bookmarks()

  • 原文:http://codex.wordpress.org/Function_Reference/get_bookmarks
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT