wp_delete_category()通过分类id删除一个分类

目录

描述

Deletes one existing category.

wp_delete_category() 描述

用法

<?php wp_delete_category$cat_ID ?>

wp_delete_category() 用法

参数

$cat_ID

(integer) (必填)

默认值: None

wp_delete_category() 参数

返回值

(mixed) 

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.

wp_delete_category() 返回值

示例

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

<?php
$categ_ID = 3;
if ( wp_delete_category( $categ_ID ) ) {
  echo "Category #$categ_ID was successfully deleted";
} else {
  echo "Impossible to delete category #$categ_ID! Make sure it exists and that it's not the default category";
}
?>

wp_delete_category() 示例

历史

添加于 版本: 2.0.0

wp_delete_category() 历史

源文件

wp_delete_category() 函数的代码位于 wp-includes/taxonomy.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Deletes one existing category.
 *
 * @since 2.0.0
 *
 * @param int $cat_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.
 */
function wp_delete_category( $cat_ID ) {
	return wp_delete_term( $cat_ID, 'category' );
}

wp_delete_category() 源文件