数字化技能提升教程,数字化时代生存宝典

数字化百科 / 产品文档 / WordPress:Function Reference/get categories

WordPress:Function Reference/get categories

查看全部产品文档命名空间:WordPress

描述

返回与查询参数匹配的类别objects的数组。

参数与wp_list_categories非常相像,可以用来作为数组传递,或者在查询语法中传递。

用法

%%% %%%

例子

默认用法

%%% 'post',
'child_of' => 0,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true,
'include_last_update_time' => false,
'hierarchical' => 1,
'exclude' => ,
'include' =>
,
'number' => ,
'pad_counts' => false);?>%%%

下拉列表框

下面是创建如,存档有文章记录的类别的子类别的下拉列表框。这反映了 wp_get_archives下面列表的例子, wp_get_archives显示怎样为按月的存档创建下拉列表框。

假如你想要显示的子类别的上级类别是10,而且类别"昵称"是"存档"。



参数

; type (string) :需要返回的类别的类型 :* post - 默认 :* link

; child_of (

integer) :只显示某个类别ID的子类别。这个参数没有默认设置。如果使用了这个参数,hide_empty参数设置为false。
; orderby (
string):根据字母表属性或者类别ID给类别分类。默认为根据类别 ID分类。有效的参数值:
:* ID - 默认
:* name
; order (
string):类别的分类顺序(升序或者降序)。默认为升序。有效的参数值:
:* asc - 默认
:* desc

; hide_empty (

boolean): Toggles没有文章的类别的显示。默认为正确的(隐藏空类别)。有效的参数值:
:* 1 (true) - 默认的
:* 0 (false)

; include_last_update_time (

boolean):不确定what this doesies|the example]]。
:* 1 (true)
:* 0 (false) -- 默认

; hierarchical (

boolean):将子类别显示为内嵌的列表内容(母类别下面)或者内套。默认为true(在母列表内容的下面显示子类别)。有效的参数值:

:* 1 (true) -默认的
:* 0 (false)

; exclude (

string):从wp_list_categories产生的列表中删除一个或者更多的类别。这个参数有一个用逗号分开的类别ID,以升序排列。

请看看例子。

; include (

string):在wp_list_categories产生的列表中只包含某些类别。这个参数有一个用逗号分开的类别ID的列表,以升序排列。
请看看例子。

:* list -默认。
:* none
; number (

string) : 返回的类别数字
; pad_counts (
boolean''): 包含子类别的内容,技术链接或者文章字数。有效的参数值:
:* 1 (true)
:* 0 (false) -默认