wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



category_exists › WordPress Function

Depuis2.0.0
Dépréciéen/a
category_exists ( $cat_name, $category_parent = null )
Paramètres: (2)
  • (int|string) $cat_name Category name.
    Requis: Oui
  • (int) $category_parent Optional. ID of parent category.
    Requis: Non
    Défaut: null
Voir:
Retourne:
  • (string|null) Returns the category ID as a numeric string if the pairing exists, null if not.
Défini(e) dans:
Codex:

Checks whether a category exists.



Source

function category_exists( $cat_name, $category_parent = null ) {
	$id = term_exists( $cat_name, 'category', $category_parent );
	if ( is_array( $id ) ) {
		$id = $id['term_id'];
	}
	return $id;
}