函数文档

wp_delete_category()

💡 云策文档标注

概述

wp_delete_category() 函数用于删除 WordPress 中的一个现有分类。它基于 wp_delete_term() 实现,专门处理 'category' 分类法。

关键要点

  • 参数:$cat_id(整数,必需),表示要删除的分类的 term ID。
  • 返回值:可能返回 true(删除成功)、false(分类不存在)、0(尝试删除默认分类时)或 WP_Error 对象。
  • 实现:函数内部调用 wp_delete_term($cat_id, 'category') 来执行删除操作。
  • 版本历史:自 WordPress 2.0.0 版本引入。

代码示例

function wp_delete_category( $cat_id ) {
    return wp_delete_term( $cat_id, 'category' );
}

📄 原文内容

Deletes one existing category.

Parameters

$cat_idintrequired
Category term ID.

Return

bool|int|WP_Error Returns true if completes delete action; false if term doesn’t exist; Zero on attempted deletion of default Category; WP_Error object is also a possibility.

Source

function wp_delete_category( $cat_id ) {
	return wp_delete_term( $cat_id, 'category' );
}

Changelog

Version Description
2.0.0 Introduced.

User Contributed Notes