get_category_link

Retrieve category link URL.

Description

(string) get_category_link( (int|object) $category ); 

Returns (string)

Link on success, empty string if category does not exist.

Parameters (1)

0. $category (int|object)
Category ID or object.

Usage

  1. if ( !function_exists( 'get_category_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/category-template.php'; 
  3.  
  4. // Category ID or object. 
  5. $category = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_category_link($category); 
  9.  

Defined (1)

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

/wp-includes/category-template.php  
  1. function get_category_link( $category ) { 
  2. if ( ! is_object( $category ) ) 
  3. $category = (int) $category; 
  4.  
  5. $category = get_term_link( $category, 'category' ); 
  6.  
  7. if ( is_wp_error( $category ) ) 
  8. return ''; 
  9.  
  10. return $category;