Ïê½âWordPressÖзÖÀຯÊýwp_list_categoriesµÄʹÓÃ

5年以前  |  阅读数:383 次  |  编程语言:PHP 

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¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例