wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



category_exists › WordPress Function

Od2.0.0
Przestarzałyn/a
category_exists ( $cat_name, $category_parent = null )
Parametry: (2)
  • (int|string) $cat_name Category name.
    Wymagane: Tak
  • (int) $category_parent Optional. ID of parent category.
    Wymagane: Nie
    Domyślny: null
Zobacz:
Powrót:
  • (string|null) Returns the category ID as a numeric string if the pairing exists, null if not.
Zdefiniowane na:
Codex:

Checks whether a category exists.



Źródło

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