get_category_feed_link( int $cat_id, string $feed = '' )
Retrieves the feed link for a category.
Description Description
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.
Parameters Parameters
- $cat_id
-
(int) (Required) Category ID.
- $feed
-
(string) (Optional) Feed type. Possible values include 'rss2', 'atom'. Default is the value of get_default_feed().
Default value: ''
Return Return
(string) Link to the feed for the category specified by $cat_id.
Source Source
File: wp-includes/link-template.php
function get_category_feed_link( $cat_id, $feed = '' ) {
return get_term_feed_link( $cat_id, 'category', $feed );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example
Return the rss2 feed link for post in category 2
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>'; } }