wp_update_category( array $catarr )

Aliases wp_insert_category() with minimal args.


Description Description

If you want to update only some fields of an existing category, call this function with only the new values set inside $catarr.


Parameters Parameters

$catarr

(array) (Required) The 'cat_ID' value is required. All other keys are optional.


Top ↑

Return Return

(int|bool) The ID number of the new or updated Category on success. Zero or FALSE on failure.


Top ↑

Source Source

File: wp-admin/includes/taxonomy.php

function wp_update_category( $catarr ) {
	$cat_ID = (int) $catarr['cat_ID'];

	if ( isset( $catarr['category_parent'] ) && ( $cat_ID == $catarr['category_parent'] ) ) {
		return false;
	}

	// First, get all of the original fields
	$category = get_term( $cat_ID, 'category', ARRAY_A );
	_make_cat_compat( $category );

	// Escape data pulled from DB.
	$category = wp_slash( $category );

	// Merge old and new fields with new fields overwriting old ones.
	$catarr = array_merge( $category, $catarr );

	return wp_insert_category( $catarr );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.