Function Reference/get links

来自WordPress中文文档
(重定向自Template Tags/get links
跳转至: 导航搜索

wordpress.org.cn


includeonlydiv style=clear:both; background-color:#FFFFFF; border:1px solid #FFFFFF; color:#c00; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also onlyincludecodewp-includes/deprecated.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude


Description

Like wp_get_links(), this tag displays links from the Links Manager, but allows the user to control how they are displayed by tag parameters, rather than through the WordPress admin interface (useful when displaying links on more than one template). This tag does ignore any link where the Visible property is set to No.

Replace With

wp_list_bookmarks().

Usage

%%% ?php get_links(category, 'before', 'after', 'between', show_images, 'order', show_description,show_rating, limit, show_updated, echo); ? %%%

Examples

Default Usage

By default, the usage shows:

  • All links
  • Line breaks after each link item
  • An image if one is included
  • A space between the image and the text
  • Sorts the list by name
  • Shows the description of the link
  • Does not show the ratings
  • Unless limit is set, shows all links
  • Displays links as links not text
?php get_links(); ?

Specific Category Sorted by URL

Displays links for link category ID 2 in span tags, uses images for links, does not show descriptions, sorts by link URL.

?php get_links(2, 'lt;spangt;', 'lt;/spangt;', #39;#39;, TRUE, 'url', FALSE); ?

Shows Ratings and Timestamp

Displays all links in an ordered list with descriptions on a new line, does not use images for links, sorts by link id, shows description, show rating, no limit to the number of links, shows last-updated timestamp, and echoes the results.

lt;olgt;
?php get_links('-1', 'lt;ligt;', 'lt;/ligt;', 'lt;br /gt;', FALSE, 'id', TRUE, 
TRUE, -1, TRUE, TRUE); ?
lt;/olgt;

Parameters

category 
(integer) The numeric ID of the link category whose links will be displayed. Display links in multiple categories by passing a string containing comma-separated list of categories, e.g. 4,11,3. If none is specified, all links are shown. Defaults to tt-1/tt (all links).
before 
(string) Text to place before each link. There is no default.
after 
(string) Text to place after each link. Defaults to tt'lt;br /gt;'/tt.
between 
(string) Text to place between each link/image and its description. Defaults to tt' '/tt (space).
show_images 
(boolean) Should images for links be shown (ttTRUE/tt) or not (ttFALSE/tt). Defaults to ttTRUE/tt.
order 
(string) Value to sort links on. Defaults to tt'name'/tt unless you pass the value of tt#39;#39;/tt (empty), in which case it sets to tt'id'/tt. Valid options:
  • tt'id'/tt
  • tt'url'/tt
  • tt'name'/tt
  • tt'target'/tt
  • tt'category'/tt
  • tt'description'/tt
  • tt'owner'/tt - User who added link through Links Manager.
  • tt'rating'/tt
  • tt'updated'/tt
  • tt'rel'/tt - Link relationship (XFN).
  • tt'notes'/tt
  • tt'rss'/tt
  • tt'length'/tt - The length of the link name, shortest to longest.
Prefixing any of the above options with an underscore (ex: tt'_id'/tt) sorts links in reverse order.
  • tt'rand'/tt - Display links in random order.
show_description 
(boolean) Should the description be displayed (ttTRUE/tt) or not (ttFALSE/tt). Valid when show_images is ttFALSE/tt, or an image is not defined. Defaults to ttTRUE/tt.
show_rating 
(boolean) Should rating stars/characters be displayed (ttTRUE/tt) or not (ttFALSE/tt). Defaults to ttFALSE/tt.
limit 
(integer) Maximum number of links to display. Defaults to tt-1/tt (all links).
show_updated 
(boolean) Should the last updated timestamp be displayed (ttTRUE/tt) or not (ttFALSE/tt). Defaults to ttFALSE/tt.
echo 
(boolean) Display links (ttTRUE/tt) or return them for use PHP (ttFALSE/tt). Defaults to ttTRUE/tt.

Related

get_bookmark, get_bookmark_field, get_bookmarks, wp_list_bookmarks

includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude