WordPress at a glance

get_the_category_by_ID() WP 1.0

Retrieve category name based on category ID.

Works based on: get_term()

No Hooks.

Return

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

Usage

get_the_category_by_ID( $cat_ID );
$cat_ID(int) (required)
Category ID.

Code of get_the_category_by_ID: wp-includes/category-template.php VER 5.0

<?php
function get_the_category_by_ID( $cat_ID ) {
	$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
    Hello, !     Log In . Register