站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Function Reference/get categories
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
Fludlen
(
讨论
|
贡献
)
2008年7月19日 (六) 16:10的版本
(
差异
)
←上一版本
|
最后版本
(
差异
) |
下一版本→
(
差异
)
跳转至:
导航
、
搜索
警告:您正在编辑的是本页面的旧版本。
如果您发布该更改,该版本后的所有更改都会丢失。
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
== Description == ==描述 == Returns an array of category objects matching the query parameters. 返回与查询参数匹配的类别objects的数组。 Arguments are pretty much the same as [[WordPress:Template_Tags/wp_list_categories|wp_list_categories]] and can be passed as either array or in query syntax. <!--The array returned seems to be always flat (no nesting for subcategories) but I'm not sure yet.--> 参数与[[WordPress:Template_Tags/wp_list_categories|wp_list_categories]]非常相像,可以用来作为数组传递,或者在查询语法中传递。<!—返回的数组似乎总是flat (没有嵌套的子类别)但是我还不确定。--> == Usage == == 用法 == %%% <?php $categories = get_categories(parameters); ?> %%% %%% <?php $categories = get_categories(parameters); ?> %%% == Examples == === Default Usage === == 例子== ===默认用法=== %%% <?php $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'pad_counts' => false);?>%%% %%% <?php $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'pad_counts' => false);?>%%% === Dropdown Box === === 下拉列表框 === Here's how to create a dropdown box of the subcategories of, say, a category that archives information on past events. This mirrors the example of the dropdown example of [[WordPress:Template_Tags/wp_get_archives | wp_get_archives]] which shows how to create a dropdown box for monthly archives. 下面是创建如,存档有文章记录的类别的子类别的下拉列表框。这反映了[[WordPress:Template_Tags/wp_get_archives | wp_get_archives]]下面列表的例子,[[WordPress:Template_Tags/wp_get_archives | wp_get_archives]]显示怎样为按月的存档创建下拉列表框。 Suppose the category whose subcategories you want to show is category 10, and that its category "nicename" is "archives". 加入你想要显示的子类别的上级类别是10,而且类别"昵称"是"存档"。 <pre> <select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo attribute_escape(__('Select Event')); ?></option> <?php $categories= get_categories('child_of=10'); foreach ($categories as $cat) { $option = '<option value="/category/archives/'.$cat->category_nicename.'">'; $option .= $cat->cat_name; $option .= ' ('.$cat->category_count.')'; $option .= '</option>'; echo $option; } ?> </select> </pre> <pre> <select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo attribute_escape(__('Select Event')); ?></option> <?php $categories= get_categories('child_of=10'); foreach ($categories as $cat) { $option = '<option value="/category/archives/'.$cat->category_nicename.'">'; $option .= $cat->cat_name; $option .= ' ('.$cat->category_count.')'; $option .= '</option>'; echo $option; } ?> </select> </pre> == Parameters == == 参数 == ; '''type''' (''string'') : Type of category to retrieve ; '''type''' (''string'') :需要返回的类别的类型 :* <tt>post</tt> - default :* <tt>link</tt> :* <tt>post</tt> - 默认 :* <tt>link</tt> ; '''child_of''' (''integer'') :Only display categories that are children of the category identified by its ID. There is no default for this parameter. If the parameter is used, the '''hide_empty''' parameter is set to ''false''. ; '''child_of''' (''integer'') :只显示某个类别ID的子类别。这个参数没有默认设置。如果使用了这个参数,'''hide_empty'''参数设置为''错误的''。 ; '''orderby''' (''string''):Sort categories alphabetically or by unique category ID. The default is ''sort by Category ID''. Valid values: ; '''orderby''' (''string''):根据字母表属性或者类别ID给类别分类。默认为''根据类别 ID分类''。有效的参数值: :* <tt>ID</tt> - default :* <tt>name</tt> :* <tt>ID</tt> - 默认 :* <tt>name</tt> ; '''order''' (''string''):Sort order for categories (either ascending or descending). The default is ''ascending''. Valid values: ; '''order''' (''string''):类别的分类顺序(升序或者降序)。默认为''升序''。有效的参数值: :* <tt>asc</tt> - default :* <tt>desc</tt> :* <tt>asc</tt> - 默认 :* <tt>desc</tt> ; '''hide_empty''' (''boolean''):Toggles the display of categories with no posts. The default is ''true'' (hide empty categories). Valid values: ; '''hide_empty''' (''boolean''): Toggles没有文章的类别的显示。默认为''正确的''(隐藏空类别)。有效的参数值: :* <tt>1 (true)</tt> - default :* <tt>0 (false)</tt> :* <tt>1 (true)</tt> - 默认的 :* <tt>0 (false)</tt> ; '''include_last_update_time''' (''boolean''): Uncertain what this doesies|the example]]. ; '''include_last_update_time''' (''boolean''):不确定what this doesies|the example]]。 :* <tt>1 (true)</tt> :* <tt>0 (false)</tt> -- default :* <tt>1 (true)</tt> :* <tt>0 (false)</tt> -- 默认 ; '''hierarchical''' (''boolean''):Display sub-categories as inner list items (below the parent list item) or inline. The default is ''true'' (display sub-categories below the parent list item). Valid values: ; '''hierarchical''' (''boolean''):将子类别显示为内嵌的列表内容(母类别下面)或者内套。默认为''正确的''(在母列表内容的下面显示子类别)。有效的参数值: :* <tt>1 (true)</tt> - default :* <tt>0 (false)</tt> :* <tt>1 (true)</tt> -默认的 :* <tt>0 (false)</tt> ; '''exclude''' (''string''):Excludes one or more categories from the list generated by ''wp_list_categories''. This parameter takes a comma-separated list of categories by unique ID, in ascending order. ; '''exclude''' (''string''):从''wp_list_categories''产生的列表中删除一个或者更多的类别。这个参数有一个用逗号分开的类别ID,以升序排列。 See [[WordPress:Template_Tags/wp_list_categories#Include_or_Exclude_Categories|the example]]. 请看看[[WordPress:Template_Tags/wp_list_categories#Include_or_Exclude_Categories|例子]]。 ; '''include''' (''string''):Only include certain categories in the list generated by ''wp_list_categories''. This parameter takes a comma-separated list of categories by unique ID, in ascending order. See [[WordPress:Template_Tags/wp_list_categories#Include_or_Exclude_Categories|the example]]. ; '''include''' (''string''):在''wp_list_categories''产生的列表中只包含某些类别。这个参数有一个用逗号分开的类别ID的列表,以升序排列。 请看看[[WordPress:Template_Tags/wp_list_categories#Include_or_Exclude_Categories|例子]]。 :* <tt>list</tt> - default. :* <tt>none</tt> ; '''number''' (''string'') : The number of categories to return ; '''pad_counts''' (''boolean''): Calculates link or post counts by including items from child categories. Valid values: :* <tt>1 (true)</tt> :* <tt>0 (false)</tt> - default :* <tt>list</tt> -默认。 :* <tt>none</tt> ; '''number''' (''string'') : 返回的类别数字 ; '''pad_counts''' (''boolean''): 包含子类别的内容,技术链接或者文章字数。有效的参数值: :* <tt>1 (true)</tt> :* <tt>0 (false)</tt> -默认
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)