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



get_the_category_by_id › WordPress Function

Od0.71
Przestarzałyn/a
get_the_category_by_id ( $cat_id )
Parametry:
  • (int) $cat_id Category ID.
    Wymagane: Tak
Powrót:
  • (string|WP_Error) Category name on success, WP_Error on failure.
Zdefiniowane na:
Codex:

Retrieves category name based on category ID.



Źródło

function get_the_category_by_ID( $cat_id ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
	$cat_id   = (int) $cat_id;
	$category = get_term( $cat_id );

	if ( is_wp_error( $category ) ) {
		return $category;
	}

	return ( $category ) ? $category->name : '';
}