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



category_exists › WordPress Function

Desde2.0.0
Obsoleton/a
category_exists ( $cat_name, $category_parent = null )
Parâmetros: (2)
  • (int|string) $cat_name Category name.
    Required: Yes
  • (int) $category_parent Optional. ID of parent category.
    Required: No
    Padrão: null
Ver:
Retorna:
  • (string|null) Returns the category ID as a numeric string if the pairing exists, null if not.
Definido em:
Codex:

Checks whether a category exists.



Fonte

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