On this page
get_links_list( string $order = 'name' )
This function has been deprecated. Use wp_list_bookmarks() instead.
Output entire list of links by category.
Description
Output a list of all links, listed by category, using the settings in $wpdb->linkcategories and output it as a nested HTML unordered list.
See also
Parameters
$orderstring Optional-
Sort link categories by
'name'or'id'Default:
'name'
Source
File: wp-includes/deprecated.php. View all references
function get_links_list($order = 'name') {
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_list_bookmarks()' );
$order = strtolower($order);
// Handle link category sorting.
$direction = 'ASC';
if ( '_' == substr($order,0,1) ) {
$direction = 'DESC';
$order = substr($order,1);
}
if ( !isset($direction) )
$direction = '';
$cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0));
// Display each category.
if ( $cats ) {
foreach ( (array) $cats as $cat ) {
// Handle each category.
// Display the category name.
echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n";
// Call get_links() with all the appropriate params.
get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false);
// Close the last category.
echo "\n\t</ul>\n</li>\n";
}
}
}
Hooks
- apply_filters( 'link_category',
string $cat_name ) -
Filters the category name.
Related
Uses
| Uses | Description |
|---|---|
| get_links() wp-includes/deprecated.php | Gets the links associated with category by ID. |
| get_categories() wp-includes/category.php | Retrieves a list of category objects. |
| _deprecated_function() wp-includes/functions.php | Marks a function as deprecated and inform when it has been used. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Use wp_list_bookmarks() |
| 1.0.1 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_links_list