Retrieves category link URL.
Description
See also
Parameters
$category
int|objectrequired- Category ID or object.
Source
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; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
Category Link
Worth remembering that a category_id is a term_id and not a term_taxonomy_id
(And, yes, you can figure that out from reading the code. But these sometimes will be the same, fooling some people into thinking that the term_taxonomy_id was right. But sooner or later you will probably get examples where they are different, and then things do not work right.)
Example of a categories list with the Bootstrap 5 card and badge count.