wp_list_categories º¯ÊýÊÇ WordPress ÖÐÓÃÀ´ÂÞÁÐϵͳÖÐ*ÖÀaµÄº¯Êý£¬¸Ãº¯ÊýÓµÓÐÐi¶a¿ØÖÆÊa³oµÄ²ÎÊý£¬½ñÌiͻȻ±»Ò»¸oÅoÓÑÎʵ½£¬ËuÒԾʹo¸ÅÕuÀiÁËһϡ£
ÒoΪ WordPress ÖÐÄÚÖÃÀ(C)Õ¹µÄС¹¤¾ß¹¦ÄÜ£¬
ËuÒÔÎÒÃDz»¾Èκκ¯Êý¾Í¿ÉÒÔÔÚ±ßÀ¸»oÊÇÆaËuÎÒÃÇÏeÒªµÄλÖÃÏÔʾһ¸o*ÖÀaÁбi£¬
ËuÒÔwp_list_categoriesº¯Êý¾ÍºÜÉÙÓÐÈËÓõ½£¬
¸Ãº¯ÊýʹÓÃÆðÀ´ÓеaÀaËÆÓÚwp_list_bookmarks£¬
wp_list_categories ÃeÊo
wp_list_categories º¯ÊýÊÇ WordPress ÖÐÓÃÀ´ÂÞÁÐϵͳÖÐÖÀaÁ´½ÓµÄº¯Êý¡£
Ó¢ÎÄÔÎľͲ»ÉÏÁË£¬ÓÐÐËȤµÄ¿ÉÒÔÈ¥¿´Ò»Ï¹ٽÎĵµ¡£
*Óè
**
<?php
wp_list_categories( $args );
$args = array(
'show_option_all' => '',//ÊÇ*ñÁгo*ÖÀaÁ´½Ó
'orderby' => 'name',//°´Ãu³ÆÅÅÁÐ
'order' => 'ASC',//Éý¡¢½µÐo
'style' => 'list',//ÊÇ*ñÓÃÁбi£¨ul>li£(C)
'show_count' => 0,//ÊÇ*ñÏÔʾÎÄÕÂÊýÁ¿
'hide_empty' => 1,//ÊÇ*ñÏÔʾÎÞÈÕÖ¾*ÖÀa
'use_desc_for_title' => 1,//ÊÇ*ñÏÔʾ*ÖÀaÃeÊo
'child_of' => 0,//ÊÇ*ñÏÞÖÆ×Ó*ÖÀa
'feed' => '',//ÊÇ*ñÏÔʾrss
'feed_type' => '',//rssÀaÐÍ
'feed_image' => '',//ÊÇ*ñÏÔʾrssͼƬ
'exclude' => '',//Åųý*ÖÀaµÄID£¬¶a¸oÓÃ',£¨Ó¢ÎĶººÅ£(C)'*Ö¸o
'exclude_tree' => '',//Åųý*ÖÀaÊ÷£¬¼´¸¸*ÖÀa¼°ÆaϵÄ×Ó*ÖÀa
'include' => '',//°uÀ¨µÄ*ÖÀa
'hierarchical' => true,//ÊÇ*ñ½«×Ó¡¢¸¸*ÖÀa*Ö¼¶
'title_li' => __( 'Categories' ),//Áбi±eÌaµÄÃu³Æ
'show_option_none' => __('No categories'),//ÎÞ*ÖÀaʱÏÔʾµÄ±eÌa
'number' => null,//ÏÔʾ*ÖÀaµÄÊýÁ¿
'echo' => 1,//ÊÇ*ñÏÔʾ£¬ÏÔʾ»oÕß*µ»Ø×Ö*u´®
'depth' => 0,//²a¼¶ÏÞÖÆ
'current_category' => 0,//Ìi¼ÓÒ»¸oûÓеÄ*ÖÀa
'pad_counts' => 0,//Õa¸oÎÒÒ²²»Ã÷°×
'taxonomy' => 'category',//ʹÓõÄ*ÖÀa*¨
'walker' => null//ÓÃÓÚÏÔʾµÄÀa£¨ºÜ¸´ÔӵĸÅÄi£(C)
?>
¹ØÓÚ'pad_counts'£¬ÎÒҲû¸aÃ÷°×Õa¸o²ÎÊýÊǸÉʲôÓõģ¬
Èç¹uÓÐÐËȤÄa¿ÉÒÔÑо¿Ò»ÏÂÕa¸o²ÎÊýµÄ¹Ù*½Îĵµ¡£
Ò²¿ÉÒÔ¶ÔÕÕÒ»ÏÂwp_list_bookmarksȥʹÓá£
pad_counts
(boolean) Calculates link or post counts by including items from child categories. If show_counts and hierarchical are true this is automatically set to true. This parameter added at Version 2.9 Valid values:
1 (true)
0 (false) ¨C default
ʹÓÃʵÀý
ÏÔʾ°uÀ¨IDΪ3,5,9,16µÄ*ÖÀaÁ´½Ó£¬ÇÒ°´Ãu³ÆÅÅÁÐ˳Ðo
<ul>
<?php wp_list_categories('orderby=name&include;=3,5,9,16'); ?>
</ul>
ÏÔʾPoetryΪ±eÌaµÄ°uÀ¨IDΪ5,9,23µÄ*ÖÀaÁбi
<ul>
<?php wp_list_categories('include=5,9,23&title;_li=<h2>' . __('Poetry') . '</h2>' ); ?>
</ul>
µ±È»ÄaÒ²¿ÉÒÔÏñÈçÏÂÕaÑuÊeд²ÎÊý£¬½«²ÎÊýÕuºÏΪÊý×e¡£
<?php
$taxonomy = 'genre';
$orderby = 'name';
$show_count = 0; // 1 for yes, 0 for no
$pad_counts = 0; // 1 for yes, 0 for no
$hierarchical = 1; // 1 for yes, 0 for no
$title = '';
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title
);
?>
<ul>
<?php wp_list_categories( $args ); ?>
</ul>
taxonomyÖÀa¨£¬ÊÇÏa¶ÔÓÚ±eÇ(C)£¨tag£(C)µÄ¸ÅÄi¡£