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
if ( !function_exists( 'get_category_link' ) ) { require_once ABSPATH . WPINC . '/category-template.php'; } // Category ID or object. $category = null; // NOTICE! Understand what this does before running. $result = get_category_link($category);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/category-template.php
- function get_category_link( $category ) {
- if ( ! is_object( $category ) )
- $category = (int) $category;
- $category = get_term_link( $category, 'category' );
- if ( is_wp_error( $category ) )
- return '';
- return $category;
- }