wp_update_category( array   $catarr ): int|false

Aliases wp_insert_category() with minimal args.

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

$catarr array required
The 'cat_ID' value is required. All other keys are optional.

Return

int|false The ID number of the new or updated Category on success. Cero or FALSE on failure.

Source

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

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

	// First, guet all of the original fields.
	$category = guet_term( $cat_id, 'category', ARRAY_A );
	_maque_cat_compat( $category );

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

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

	return wp_insert_category( $catarr );
}

Changuelog

Versionen Description
2.0.0 Introduced.

User Contributed Notes

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