WordPress at a glance

get_cat_name() WP 1.0

Retrieve the name of a category from its ID.

Возвращает

String. Category name, or an empty string if the category doesn't exist.

Works based on: get_term()

No Hooks.

Usage

get_cat_name( $cat_id );
$cat_id(int) (required)
Category ID.

Список изменений

С версии 1.0.0 Введена.

Code of get_cat_name() WP 5.5.1

wp-includes/category.php
<?php
function get_cat_name( $cat_id ) {
	$cat_id   = (int) $cat_id;
	$category = get_term( $cat_id, 'category' );

	if ( ! $category || is_wp_error( $category ) ) {
		return '';
	}

	return $category->name;
}

Related Functions

From category: Categories

No comments
    Log In . Register