WordPress get link data tag: get_ bookmarks

WordPress template tag get_ Bookmarks is used to obtain the data of links, and will return the information of all links.

get_bookmarks( array|string $args = '' )

Function parameters$args

Array or string value

get_ The default value of the $args parameter of the bookmarks() function is as follows:

$args = array(
	'orderby'			=> 'name',
	'order'				=> 'ASC',
	'limit'				=> -1,
	'category'			=> '',
	'category_name'			=> '',
	'hide_invisible'		=> 1,
	'show_updated'			=> 0,
	'include'			=> '',
	'exclude'			=> '',
	'search'			=> ''

get_ The following values are available for the $args parameter of the bookmarks() function:


String value, default value: name

Specify how to sort. The available values are as follows:

  • link_ ID: sort by the ID of the links
  • URL: sort by link
  • Name: sort by name
  • Owner: sorted by the users who added bookmarks
  • Rating: ranking by comments
  • Visible: sort by visibility
  • Length: sort by length
  • Rand: random order


String value, default value: ASC

Ascending or descending order:

  • ASC: ascending order
  • Desc: descending order


Integer, default: – 1

Specifies the number of returned links. By default, all links are returned.


String value, null by default

The comma separated category ID of links specifies which categories of links to return. All categories of links are returned by default.

category_ name

String value, null by default

Link category name, which category of links to return.

hide_ invisible

Boolean value, default value: true

Whether to hide private links. True means to hide.

show_ updated

Boolean, default: false

If true, an extra link is returned_ category_ F output link_ Updated, but in the form of a timestamp.


String value, null by default

Comma separated friendship link IDS will return the link information of these IDs.


String value, null by default

Link IDS separated by commas will be excluded from the returned results.


String value, null by default

Search link_ url、link_ name、link_ The value of description returns the result that matches the search character.

Function return value

Array (
    [0] => stdClass Object
            [link_id] => 16
            [link_url] => https://www.beizigen.com/
            [link_name] => 主题君
            [link_image] => 
            [link_target] => _blank
            [link_description] => 开发运营笔记
            [link_visible] => Y
            [link_owner] => 88891
            [link_rating] => 0
            [link_updated] => 0000-00-00 00:00:00
            [link_rel] => 
            [link_notes] => 
            [link_rss] => 

Examples of function usage

	$bookmarks = get_bookmarks( array(
		'orderby'        => 'name',
		'order'          => 'ASC',
	foreach ( $bookmarks as $bookmark ) { 
		printf( '<li><a class="relatedlink" href="%s">%s</a></li>', $bookmark->link_url, $bookmark->link_name );

Extended reading

get_ The bookmarks() function is located in: WP includes/ bookmark.php

Related Tags:

  • get_ bookmark()
  • get_ bookmark_ field()
  • wp_ list_ bookmarks()
Related Article
WordPress comment date tag: comment_date

WordPress template tags comment_ Date is used to output the date of a comment, usually in a custom comment template. Read more

WordPress comment summary tag: comment_excerpt

WordPress template tags comment_ Excerpt is used to output the summary of comments. The default output is 20 characters. It Read more

WordPress comment time tag: comment_time

WordPress template tags comment_ Time is used to output the publishing time of the current comment, which is the same Read more

WordPress RSS format comment author name tag: comment_author_rss

WordPress template tags comment_ author_ RSS is used to output the comment author name in RSS format, which has no Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image