美工统筹SEO,为企业电子商务营销助力!
详解WordPress平分类函数wp_list_categories的利用一佰互联网站扶植(www.taishanly.com) 宣布时候:2020-04-27 10:44:33 阅读数: 94 |
wp_list_categories 函数是 WordPress 顶用来枚举体系平分类的函数,该函数具有很多节制输入的参数,明天俄然被一个伴侣问到,以是就大要清算了一下。 由于 WordPress 中内置扩大的小东西功效,以是咱们不经任何函数就能够在边栏或是其余咱们想要的地位显现一个分类列表,以是wp_list_categories函数就很少有人用到,该函数利用起来有点近似于wp_list_bookmarks, wp_list_categories 描写wp_list_categories 函数是 WordPress 顶用来枚举体系平分类链接的函数。英文原文就不上了,有乐趣的能够去看一下官方文档。 用法 <?php wp_list_categories( $args ); $args = array( "show_option_all" => "",//是不是列出分类链接 "orderby" => "name",//按称号摆列 "order" => "ASC",//升、降序 "style" => "list",//是不是用列表(ul>li) "show_count" => 0,//是不是显现文章数目 "hide_empty" => 1,//是不是显现无日记分类 "use_desc_for_title" => 1,//是不是显现分类描写 "child_of" => 0,//是不是限定子分类 "feed" => "",//是不是显现rss "feed_type" => "",//rss范例 "feed_image" => "",//是不是显现rss图片 "exclude" => "",//解除分类的ID,多个用",(英文逗号)"分开 "exclude_tree" => "",//解除分类树,即父分类及其下的子分类 "include" => "",//包含的分类 "hierarchical" => true,//是不是将子、父分类分级 "title_li" => __( "Categories" ),//列表标题的称号 "show_option_none" => __("No categories"),//无分类时显现的标题 "number" => null,//显现分类的数目 "echo" => 1,//是不是显现,显现或前往字符串 "depth" => 0,//层级限定 "current_category" => 0,//增加一个不的分类 "pad_counts" => 0,//这个我也不大白 "taxonomy" => "category",//利用的分类法 "walker" => null//用于显现的类(很庞杂的观点)?> 对"pad_counts",我也没搞大白这个参数是干甚么用的,若是有乐趣你能够研讨一下这个参数的官方文档。也能够对比一下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) – default 利用实例显现包含ID为3,5,9,16的分类链接,且按称号摆列挨次 <ul><?php wp_list_categories("orderby=name&include=3,5,9,16"); ?> </ul> 显现Poetry为标题的包含ID为5,9,23的分类列表 <ul><?php wp_list_categories("include=5,9,23&title_li=<h2>" . __("Poetry") . "</h2>" ); ?> </ul> 固然你也能够像以下如许誊写参数,将参数整合为数组。 <?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分类法,是绝对标签(tag)的观点。 |
上一篇:在WordPress中装置利用视频播放器插件Hana Flv Player 下一篇: 大师须知简略的php机能优化注重点 |
[前往消息列表] |