函数文档

wp_set_post_cats()

💡 云策文档标注

概述

wp_set_post_cats() 是一个已弃用的 WordPress 函数,用于设置文章的分类。自 WordPress 2.1.0 起,建议使用 wp_set_post_categories() 替代。

关键要点

  • wp_set_post_cats() 已弃用,自版本 2.1.0 起应改用 wp_set_post_categories()。
  • 函数接受三个参数:$blogid(未使用)、$post_id(必需)和 $post_categories(可选,默认为空数组)。
  • 返回值为 bool 或 mixed 类型,具体取决于 wp_set_post_categories() 的返回值。
  • 函数内部调用 _deprecated_function() 来标记弃用状态。

注意事项

在开发中应避免使用此函数,以保持代码的现代性和兼容性。


📄 原文内容

Sets the categories that the post ID belongs to.

Description

See also

Parameters

$blogidintrequired
Not used
$post_idintrequired
$post_categoriesarrayoptional

Default:array()

Return

bool|mixed

Source

function wp_set_post_cats($blogid = '1', $post_id = 0, $post_categories = array()) {
	_deprecated_function( __FUNCTION__, '2.1.0', 'wp_set_post_categories()' );
	return wp_set_post_categories($post_id, $post_categories);
}

Changelog

Version Description
2.1.0 Deprecated.
1.0.1 Introduced.