Codex

Function Reference/get category link

Contents

Description

Returns the correct url for a given Category ID.

Usage

<?php get_category_link$category_id ); ?> 

Parameters

$category_id
(integer) (required) The category ID whose link will be retrieved.
Default: None

Return Values

(URL) 
(string) URL with a link to the category.

Examples

Category Link

<?php
    // Get the ID of a given category
    $category_id = get_cat_ID( 'Category Name' );

    // Get the URL of this category
    $category_link = get_category_link( $category_id );
?>

<!-- Print a link to this category -->
<a href="<?php echo esc_url( $category_link ); ?>" title="Category Name">Category Name</a>

Notes

Change Log

Since: 1.0.0

Source File

get_category_link() is located in wp-includes/category-template.php.

Related

Categories: the_category(), the_category_rss(), single_cat_title(), category_description(), wp_dropdown_categories(), wp_list_categories(), get_the_category(), get_the_category_by_ID(), get_category_by_slug(), get_the_category_list(), get_category_parents(), get_category_link(), is_category(), in_category()

See also index of Function Reference and index of Template Tags.