好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

wordpress的category总结 - WordPress

wordpress的category总结

该文讲介绍wordpress分类的相关知识,有了这些知识,分类估计也差不多了.

1:第一个介绍 wp_list_categories()函数 该函数主要用来导航使用,显示所有分类的链接列表,

默认参数设置为:

$defaults  =  array (  ’show_option_all’ => ], 无链接的分类  ‘orderby’ => ‘name’, 按照分类名排序  ‘order’ => ‘ASC’, 升序  ’show_last_update’ => 0,   不显示分类中日志的最新时间戳  ’style’ => ‘list’, 用列表显示分类  ’show_count’ => 0, 0, 不显示分类下的日志数  ‘hide_empty’ => 1, Displays only Categories with posts  ‘use_desc_for_title’ => 1, 显示分类链接中 title 标签的分类描述  ‘child_of’ => 0, 子分类无限制  ‘feed’ => ], 无 feed  ‘feed_image’ => ], 无 feed 图片显示  ‘exclude’ => ], 不在分类列表中显示该分类  ‘hierarchical’ => true, 分层显示父/子分类  ‘title_li’ => __(’Categories’), 在列表前作为标题显示分类  ‘ echo ’ => 1 显示分类  ); 

2:第二个函数get_categories(),这个函数是我想循环分类,对每个分类做处理而找的,get_categories()函数可以获得分类所有信息,返回与查询参数相匹配的类别对象数组,变量与wp_list_categories基本一致,且变量可被作为数组传递,也可在查询句法中被传递.

函数说明 用法  参数说明

type (字符)post和link 其中link在新版3.0以后已被弃用,

child_of (整数)仅显示标注了编号的分类的子类,该参数无默认值,使用该参数时应将hide_empty参数设为false.

parent (整数)只显示某个父级分类以及下面的子分类(注:子分类只显示一个层级).

orderby (字符)将分类按字母顺序或独有分类编号进行排序。默认为按分类 编号排序包括ID(默认)和Name

order (字符)为类别排序(升序或降序),默认升序,可能的值包括asc(默认)和desc

hide_empty (布尔值)触发显示没有文章的分类,默认值为true(隐藏空类别),有效的值包括:1(true)和0(false).

hierarchical (布尔值)将子类作为内部列表项目(父列表项下)的层级关系,默认为true(显示父列表项下的子类),有效值包括1(true)和0(false)

exclude (字符)除去分类列表中一个或多个分类,多个可以用逗号分开,用分类ID号表示.

include (字符)只包含指定分类ID编号的分类,多个可以用逗号分开,用分类ID号表示.

pad_counts (布尔值)通过子类中的项来计算链接或文章,有效值包括1(true)和0(false),0为默认.

number (字符)将要返回的类别数量.

taxonomy (字符)返回一个分类法,这个是wordpress3.0版本后新添加的一个参数,返回的值包括category(默认)和taxonomy(一些新定义的分类名称).

该函数返回一个对象数组,每个对象的参数如下:

object(stdClass)[1947]         public   'term_id'  => &string  '1'  (length=1)         public   'name'  => &string  '未分类'  (length=9)         public   'slug'  => &string  'uncategorized'  (length=13)         public   'term_group'  => string  '0'  (length=1)         public   'term_taxonomy_id'  => string  '1'  (length=1)         public   'taxonomy'  => string  'category'  (length=8)         public   'description'  => &string  ''  (length=0)         public   'parent'  => &string  '0'  (length=1)         public   'count'  => &string  '8'  (length=1)         public   'cat_ID'  => &string  '1'  (length=1)         public   'category_count'  => &string  '8'  (length=1)         public   'category_description'  => &string  ''  (length=0)         public   'cat_name'  => &string  '未分类'  (length=9)         public   'category_nicename'  => &string  'uncategorized'  (length=13)         public   'category_parent'  => &string  '0'  (length=1) 

3:第三个函数是get_category(),通过category的id得到一个category对象的信息,和上面对象数组中的对象一样.

查看更多关于wordpress的category总结 - WordPress的详细内容...

  阅读:62次