get_category_feed_link( int|WP_Term|object $cat, string $feed = '' ): string

Retrieves the feed link for a category.


Returns a link to the feed for all posts in a given category. A specific feed can be requested or left blank to get the default feed.

Top ↑


$cat int|WP_Term|object Required
The ID or category object whose feed link will be retrieved.
$feed string Optional
Feed type. Possible values include 'rss2', 'atom'.
Default is the value of get_default_feed() .

Default: ''

Top ↑


string Link to the feed for the category specified by $cat.

Top ↑


File: wp-includes/link-template.php. View all references

function get_category_feed_link( $cat, $feed = '' ) {
	return get_term_feed_link( $cat, 'category', $feed );

Top ↑


Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 2 content
    Contributed by Codex

    Automatic display of RSS

    Display an rss link automatically when viewing a category. Insert this code on the category.php or archive.php page template.

    if ( is_category() ) {
        $category = get_category( get_query_var('cat') );
        if ( ! empty( $category ) ) {
            echo '<div class="category-feed"><a href="' . esc_url( get_category_feed_link( $category->cat_ID ) ) . '" title="' . sprintf( esc_attr__( 'Subscribe to this category', 'textdomain' ), $category->name ) . '" rel="nofollow">' . __( 'Subscribe!', 'txtdomain' ) . '</a></div>';

You must log in before being able to contribute a note or feedback.