get_the_category_by_ID( int $cat_ID )

You are here:
  • KB Home
  • get_the_category_by_ID( int $cat_ID )

Parameters Parameters

$cat_ID

(int) (Required) Category ID.


Top ↑

Return Return

(string|WP_Error) Category name on success, WP_Error on failure.


Top ↑

Source Source

File: wp-includes/category-template.php

109
110
111
112
113
114
115
116
117
118
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 : '';
}


Top ↑

Changelog Changelog

Changelog
VersionDescription
0.71Introduced.
Was this article helpful?
Dislike 0
Views: 1

Cart

Log in

Create an Account
Back to Top