get_linkcatname

Gets the name of category by id.

Description

(string) get_linkcatname( (int) $id = 0 ); 

Returns (string)

Parameters (1)

0. $id — Optional. (int)
The category to get. If no category supplied uses 0

Usage

  1. if ( !function_exists( 'get_linkcatname' ) ) { 
  2. require_once ABSPATH . WPINC . '/deprecated.php'; 
  3.  
  4. // The category to get. If no category supplied uses 0 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_linkcatname($id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/deprecated.php  
  1. function get_linkcatname($id = 0) { 
  2. _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' ); 
  3.  
  4. $id = (int) $id; 
  5.  
  6. if ( empty($id) ) 
  7. return ''; 
  8.  
  9. $cats = wp_get_link_cats($id); 
  10.  
  11. if ( empty($cats) || ! is_array($cats) ) 
  12. return ''; 
  13.  
  14. $cat_id = (int) $cats[0]; // Take the first cat. 
  15.  
  16. $cat = get_category($cat_id); 
  17. return $cat->name;