wp_get_post_cats()
云策文档标注
概述
wp_get_post_cats() 是一个已弃用的 WordPress 函数,用于检索文章的分类列表,自 2.1.0 版本起被 wp_get_post_categories() 替代。
关键要点
- 函数 wp_get_post_cats() 已弃用,建议使用 wp_get_post_categories() 替代。
- 参数 $blogid 未使用,$post_id 指定文章 ID,返回分类数组。
- 弃用信息通过 _deprecated_function() 标记,帮助开发者迁移代码。
代码示例
function wp_get_post_cats($blogid = '1', $post_id = 0) {
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' );
return wp_get_post_categories($post_id);
}注意事项
- 自 WordPress 2.1.0 版本起,此函数已弃用,新代码应避免使用。
- 相关函数 wp_get_post_categories() 位于 wp-includes/post.php,提供相同功能。
原文内容
Retrieves a list of post categories.
Description
See also
Parameters
$blogidintrequired-
Not Used
$post_idintrequired
Source
function wp_get_post_cats($blogid = '1', $post_id = 0) {
_deprecated_function( __FUNCTION__, '2.1.0', 'wp_get_post_categories()' );
return wp_get_post_categories($post_id);
}
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Deprecated. Use wp_get_post_categories() |
| 1.0.1 | Introduced. |