get_the_category_by_ID( int $cat_id )
Retrieves category name based on category ID.
Parameters
- $cat_id
-
(int) (Required) Category ID.
Return
(string|WP_Error) Category name on success, WP_Error on failure.
Source
File: wp-includes/category-template.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 : ''; }
Expand full source code Collapse full source code View on Trac View on GitHub
Changelog
Version | Description |
---|---|
0.71 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example