get_links_list

函数
get_links_list ( $order = 'name' )
参数
  • (string) $order Sort link categories by 'name' or 'id'
    Required:
    Default: 'name'
相关
  • wp_list_bookmarks()
定义位置
相关方法
get_linksget_blog_listget_linkget_links_withratingwp_get_links
引入
1.0.1
弃用
2.1.0

get_links_list: 这个函数用来检索网站上所有链接的HTML列表。

按类别输出整个链接列表。

使用$wpdb->linkcategories中的设置,按类别输出所有链接的列表,并作为嵌套的HTML无序列表输出。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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>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";
}
}
}
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>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"; } } }
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>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";
		}
	}
}

常见问题

FAQs
查看更多 >