get_category_children
函数
get_category_children ( $id, $before = '/', $after = '', $visited = array() )
- 参数
-
-
(int)
$id
Category ID to retrieve children.- Required: 是
-
(string)
$before
Optional. Prepend before category term ID. Default ‘/’.- Required: 否
- Default: ‘/’
-
(string)
$after
Optional. Append after category term ID. Default empty string.- Required: 否
- Default: (empty)
-
(array)
$visited
Optional. Category Term IDs that have already been added. Default empty array.- Required: 否
- Default: array()
-
(int)
- 返回值
-
- (string)
- 相关
-
- get_term_children()
- 定义位置
-
-
wp-includes/deprecated.php
, line 1273
-
wp-includes/deprecated.php
- 引入
- 1.2.0
- 弃用
- 2.8.0
Retrieve category children list separated before and after the term IDs.
function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { _deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' ); if ( 0 == $id ) return ''; $chain = ''; /** TODO: Consult hierarchy */ $cat_ids = get_all_category_ids(); foreach ( (array) $cat_ids as $cat_id ) { if ( $cat_id == $id ) continue; $category = get_category( $cat_id ); if ( is_wp_error( $category ) ) return $category; if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) { $visited[] = $category->term_id; $chain .= $before.$category->term_id.$after; $chain .= get_category_children( $category->term_id, $before, $after ); } } return $chain; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。