wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_create_category › WordPress Function

Desde2.0.0
Obsoleton/a
wp_create_category ( $cat_name, $category_parent = 0 )
Parâmetros: (2)
  • (int|string) $cat_name Category name.
    Required: Yes
  • (int) $category_parent Optional. ID of parent category.
    Required: No
    Padrão:
Retorna:
  • (int|WP_Error)
Definido em:
Codex:

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



Fonte

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,
		)
	);
}