WordPress at a glance

get_the_category_by_ID() WP 1.0

Retrieve category name based on category ID.

Возвращает

String/WP_Error. Category name on success, WP_Error on failure.

Works based on: get_term()

No Hooks.

Usage

get_the_category_by_ID( $cat_ID ) // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid;
$cat_ID(int) (required)
Category ID.

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

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

Code of get_the_category_by_ID() WP 5.5.1

wp-includes/category-template.php
<?php
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 : '';
}

Related Functions

From category: Categories

No comments
    Log In . Register