WordPress Links (Bookmarks) Template Tag

WordPress themes use a combination of template tags to display certain types of content, such as links (or bookmarks), blog posts, navigation menus, page content, archive links, and so on. Take a look at the template tag that tells WordPress how to display your links.

Dashboard lets you manage your links from the Links menu item. A WordPress blogroll is a list of links that you add to the Links area in the Dashboard. The specific template tag used to call those links into your template, however, are bookmarks. For simplicity, we will refer to them as links.

Here’s the tag used to display your links:

<?php wp_list_bookmarks(); ?>

The table shows the most common parameters used for the wp_list_bookmarks(); template tag.

In the Possible Values column of the table, values that appear in bold are the default values set by WordPress. Keep this convention in mind for all the parameter values.

Most Common Parameters (Query-String) for wp_list_bookmarks();
Parameter and Type Possible Values Example
categorize (Boolean)
Displays links within the assigned category.
1 (true); 0 (false) <?php wp_list_bookmarks('categorize=0'); ?>
Returns the list of links not grouped into the categories.
category (string)
Displays only the link categories specified; if none are specified, all link categories display.
Category ID numbers separated by commas. Defaults to all categories. <?php wp_list_bookmarks('category=10, 20, 30'); ?>
Displays the list of links from the categories with ID numbers 10, 20, and 30.
category_name (string)
Displays only the link categories specified by name; if none are specified, all link categories display.
Text of the category names separated by commas. Defaults to no excluded categories. <?php wp_list_bookmarks('category_name=books'); >
Displays only the links from the Books category.
category_orderby
(string)
Sorts the order in which links are displayed on your site.
Name; id; slug; count <?php wp_list_bookmarks('category_orderby=name'); ?>
Displays the link categories alphabetically by name.
title_li
(string)
Text title appears above the link list.
bookmarks
If left blank, no title displays.
<?php wp_list_bookmarks('title_li=Links'); ?>
Displays the Links heading.
<?php wp_list_bookmarks('title_li='); ?>
Displays no heading.
title_before (string)
Formatting to appear before the category title — only if the ‘categorize’ parameter is set to 1 (true).
<h2> <?php wp_list_bookmarks('title_before='<strong>'); ?>
Inserts the <strong> HTML tag in front of the link category title.
title_after (string)
Formatting to appear after the category title — only if the ‘categorize’ parameter is set to 1 (true).
</h2> <?php wp_list_bookmarks('title_after='</strong>'); ?>
Inserts the </strong> HTML tag after the link category title.
Include (string)
Lists link ID numbers, separated by commas, to include in the display.
If no ID numbers are listed, displays all links. <?php wp_list_bookmarks('include="1,2,3'); ?>
Displays only links with the IDs of 1, 2, and 3.
exclude (string)
Lists link ID numbers, separated by commas, to exclude from the display.
If no ID numbers are listed, all links display. <?php wp_list_bookmarks('exclude='4,5,6'); ?>
Displays all links except for the links with IDs of 4, 5, and 6.
orderby (string)
Tells WordPress how your link lists will be sorted.
name; id; url; target; descriptions; owner; rating; updated; rel (XFN); notes; length; rand (random) <?php wp_list_bookmarks('orderby=rand'); >
Displays the links in random order.
<?php wp_list_bookmarks('orderby='id'); ?>
Displays the links in order by ID number.
before (string)
Formatting to appear before each link in the list.
<li> <?php wp_list_bookmarks('before=<strong>'); ?>
Inserts the <strong> HTML tag before each link in the list.
after (string)
Formatting to appear after each link in the list.
</li> <?php wp_list_bookmarks('after=</strong'); ?>
Inserts the </strong> HTML tag after each link in the list.

Here are a couple examples of tags used to set a link list.

The following tag displays a list of links in the category ID of 2 and orders that list by the length of the link name (shortest to longest):

<?php wp_list_bookmarks('categorize=1&category=2&orderby=length'); ?>

This following tag displays only the list of links in a category (the Espresso category, in this example):

<?php wp_list_bookmarks('category_name=Espresso'); ?>
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com