get_links_list()

最后更新于:2021-11-26 09:16:40

get_links_list( string$order=’name’)

Output entire list of links by category.

参数

$order

(string) (Optional) Sort link categories by ‘name’ or ‘id’

Default value: ‘name’

源文件

文件: gc-includes/deprecated.php

function get_links_list($order = 'name') {
	_deprecated_function( __FUNCTION__, '2.1.0', 'gc_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>nt<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 "nt</ul>n</li>n";
		}
	}
}