get_category_link()WP 1.0.0

Retrieve category link URL.

Used By: get_tag_link()
1 time — 0.0038219 sec (very slow) | 50000 times — 3.29 sec (fast) | PHP 7.4.25, WP 5.9.2

No Hooks.

Return

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

Usage

get_category_link( $category );
$category(int|object) (required)
Category ID or object.

Notes

Changelog

Since 1.0.0 Introduced.

Code of get_category_link() WP 5.9.3

function get_category_link( $category ) {
	if ( ! is_object( $category ) ) {
		$category = (int) $category;
	}

	$category = get_term_link( $category );

	if ( is_wp_error( $category ) ) {
		return '';
	}

	return $category;
}