The category_feed_link WordPress PHP filter allows you to modify the category feed link.
Usage
add_filter('category_feed_link', 'your_custom_function', 10, 2); function your_custom_function($link, $feed) { // your custom code here return $link; }
Parameters
$link
(string) – The category feed link.$feed
(string) – Feed type. Possible values include ‘rss2’, ‘atom’.
More information
See WordPress Developer Resources: category_feed_link
Examples
Change category feed link to a custom format
Modify the category feed link to use a custom format.
add_filter('category_feed_link', 'custom_category_feed_link', 10, 2); function custom_category_feed_link($link, $feed) { $link = str_replace('feed/', 'custom-feed/', $link); return $link; }
Add a query parameter to the category feed link
Add a custom query parameter to the category feed link.
add_filter('category_feed_link', 'add_query_param_to_feed_link', 10, 2); function add_query_param_to_feed_link($link, $feed) { $link = add_query_arg('custom_param', 'value', $link); return $link; }
Change the feed type for category feed links
Change the category feed link to use the ‘atom’ feed type.
add_filter('category_feed_link', 'change_feed_type', 10, 2); function change_feed_type($link, $feed) { $link = str_replace('rss2', 'atom', $link); return $link; }
Redirect category feed links to a third-party service
Redirect the category feed link to a third-party service like Feedburner.
add_filter('category_feed_link', 'redirect_to_feedburner', 10, 2); function redirect_to_feedburner($link, $feed) { $category_id = get_query_var('cat'); $link = 'http://feeds.feedburner.com/YourFeedID-' . $category_id; return $link; }
Remove the feed type from category feed links
Remove the feed type (rss2, atom) from the category feed link.
add_filter('category_feed_link', 'remove_feed_type', 10, 2); function remove_feed_type($link, $feed) { $link = str_replace(array('/rss2', '/atom'), '', $link); return $link; }