wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_create_category › WordPress Function

Da2.0.0
Deprecaton/a
wp_create_category ( $cat_name, $category_parent = 0 )
Parametri: (2)
  • (int|string) $cat_name Category name.
    Richiesto:
  • (int) $category_parent Optional. ID of parent category.
    Richiesto: No
    Default:
Ritorna:
  • (int|WP_Error)
Definito a:
Codex:

Adds a new category to the database if it does not already exist.



Sorgenti

function wp_create_category( $cat_name, $category_parent = 0 ) {
	$id = category_exists( $cat_name, $category_parent );
	if ( $id ) {
		return $id;
	}

	return wp_insert_category(
		array(
			'cat_name'        => $cat_name,
			'category_parent' => $category_parent,
		)
	);
}