WordPress.org

Ready to get started?Download WordPress

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

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