函数文档

dropdown_categories()

💡 云策文档标注

概述

dropdown_categories() 是一个已弃用的 WordPress 函数,用于生成分类复选框控件。自 WordPress 2.6.0 起,建议使用 wp_category_checklist() 替代。

关键要点

  • 函数已弃用:自 WordPress 2.6.0 版本起,dropdown_categories() 被标记为弃用,应改用 wp_category_checklist()。
  • 功能替代:该函数原本用于生成分类复选框列表,现在由 wp_category_checklist() 提供相同功能。
  • 参数无效:所有参数($default_category、$category_parent、$popular_ids)均未使用,调用时会被忽略。
  • 内部调用:函数内部直接调用 wp_category_checklist() 并传递 $post_ID 全局变量。

代码示例

function dropdown_categories( $default_category = 0, $category_parent = 0, $popular_ids = array() ) {
    _deprecated_function( __FUNCTION__, '2.6.0', 'wp_category_checklist()' );
    global $post_ID;
    wp_category_checklist( $post_ID );
}

注意事项

  • 弃用警告:调用此函数会触发 _deprecated_function(),在开发环境中可能显示弃用通知。
  • 版本历史:函数在 WordPress 0.71 中引入,2.6.0 中弃用。
  • 相关函数:参考 wp_category_checklist() 用于生成分类复选框,_deprecated_function() 用于标记弃用。

📄 原文内容

Legacy function used to generate the categories checklist control.

Description

See also

Parameters

$default_categoryintrequired
Unused.
$category_parentintrequired
Unused.
$popular_idsarrayoptional
Unused.

Default:array()

Source

function dropdown_categories( $default_category = 0, $category_parent = 0, $popular_ids = array() ) {
	_deprecated_function( __FUNCTION__, '2.6.0', 'wp_category_checklist()' );
	global $post_ID;
	wp_category_checklist( $post_ID );
}

Changelog

Version Description
2.6.0 Deprecated. Use wp_category_checklist()
0.71 Introduced.