Example 1 — Default list
Print all links, grouped by link category.
<ul>
<?php wp_list_bookmarks(); ?>
</ul> How It Works
- The default call groups links by link category.
- Each group gets its own
<li>and heading. - Our own
<ul>wraps the list.

In WordPress, wp_list_bookmarks() builds an HTML list of bookmarks (links). By default it groups them by link category, with a heading for each group.
It prints the list. Set echo to false and it returns the HTML as a string instead.
Call it with no arguments, or pass an array to change the list.
wp_list_bookmarks();
wp_list_bookmarks( array( 'categorize' => 0, 'title_li' => '' ) );
$html = wp_list_bookmarks( array( 'echo' => false ) ); | Call | What it does |
|---|---|
wp_list_bookmarks() | Prints all visible links, grouped by link category. |
wp_list_bookmarks( array( 'categorize' => 0 ) ) | Prints one flat list without category headings. |
$html = wp_list_bookmarks( array( 'echo' => false ) ) | Returns the HTML as a string. Nothing is printed. |
With the default settings, the output is a set of <li> items. Wrap it in a <ul>.
wp_list_bookmarks( string|array $args = '' ): void|string | Parameter | Description |
|---|---|
categorize | Group links by link category. Default is 1. Use 0 for one flat list. |
title_li | Heading text for a flat list. Default is 'Bookmarks'. Use '' for no heading. |
category / category_name | Show only links from these link category IDs or this name. |
orderby / order | Sort the links. Default is name and ASC. |
limit | Maximum number of links. Default is -1 (no limit). |
show_description | Show the link description after the name. Default is 0. |
hide_invisible | Hide links marked as not visible. Default is 1. |
echo | Print the list (1, default) or return it (0 or false). |
You can pass the arguments as an array or as a query string such as 'categorize=0&limit=5'.
| Return Value | Description |
|---|---|
| void | Nothing is returned when echo is true. The list is printed. |
| string | The HTML list when echo is false. |
Three short theme examples. Each one has a sample output.
Print all links, grouped by link category.
<ul>
<?php wp_list_bookmarks(); ?>
</ul> <li> and heading.<ul> wraps the list.Show one category as a flat list, with no heading and with descriptions.
<?php
wp_list_bookmarks( array(
'category_name' => 'Friends',
'categorize' => 0,
'title_li' => '',
'show_description' => 1,
'show_images' => 0,
) );
?> categorize => 0 makes one flat list.title_li => '' removes the heading.show_description prints the description after the name. Extra attributes such as title or rel may also appear.Save the list in a variable and wrap it in your own tag.
<?php
$html = wp_list_bookmarks( array(
'echo' => false,
'categorize' => 0,
'title_li' => '',
'limit' => 2,
'show_images' => 0,
) );
if ( $html ) {
echo '<div class="blogroll">' . $html . '</div>';
}
?> echo => false returns the HTML instead of printing it.limit => 2 keeps only two links.Browse all bookmark functions in one table.
10 people found this page helpful