wp_dropdown_cats
函数
wp_dropdown_cats ( $current_cat = 0, $current_parent = 0, $category_parent = 0, $level = 0, $categories = 0 )
- 参数
-
-
(int)
$current_cat
Optional. ID of the current category. Default 0.- Required: 否
-
(int)
$current_parent
Optional. Current parent category ID. Default 0.- Required: 否
-
(int)
$category_parent
Optional. Parent ID to retrieve categories for. Default 0.- Required: 否
-
(int)
$level
Optional. Number of levels deep to display. Default 0.- Required: 否
-
(array)
$categories
Optional. Categories to include in the control. Default 0.- Required: 否
-
(int)
- 返回值
-
- (void|false) Void on success, false if no categories were found.
- 相关
-
- wp_dropdown_categories()
- 定义位置
-
-
wp-admin/includes/deprecated.php
, line 137
-
wp-admin/includes/deprecated.php
- 引入
- 1.2.0
- 弃用
- 3.0.0
Legacy function used for generating a categories drop-down control.
function wp_dropdown_cats( $current_cat = 0, $current_parent = 0, $category_parent = 0, $level = 0, $categories = 0 ) {
_deprecated_function( __FUNCTION__, '3.0.0', 'wp_dropdown_categories()' );
if (!$categories )
$categories = get_categories( array('hide_empty' => 0) );
if ( $categories ) {
foreach ( $categories as $category ) {
if ( $current_cat != $category->term_id && $category_parent == $category->parent) {
$pad = str_repeat( '– ', $level );
$category->name = esc_html( $category->name );
echo "ntterm_id )
echo " selected='selected'";
echo ">$pad$category->name";
wp_dropdown_cats( $current_cat, $current_parent, $category->term_id, $level +1, $categories );
}
}
} else {
return false;
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。