How to add more than one RSS Feed Link for wordpress

I’m using code to change Rss Feed Link for my wordpress site, it’s working but I don’t know how to add more than one rss link appear when someone click on browser Rss Icon, I need these links to appear for all pages below each other for categories “products”, “blog” and “news”.

here is the code which I’m using to change my rss link

add_filter('feed_link','custom_feed_link', 1, 2);

function custom_feed_link($output, $feed) {

    $feed_url="http://MYSITE/category/products/feed";

    $feed_array = array('rss' => $feed_url, 'rss2' => $feed_url, 'atom' => $feed_url, 'rdf' => $feed_url, 'comments_rss2' => '');
    $feed_array[$feed] = $feed_url;
    $output = $feed_array[$feed];

    return $output;
}

I tried to return array, but it can’t work, what I should do ?

enter image description here

1 Answer
1

Text that is displayed after you click on browser RSS icon depends on the feed reader you are using. I don’t think you can modify what it displays directly through WordPress (correct me if I’m wrong).

A simple workaround to achieve something similar to what you want would be placing feed links to different categories. You can place a link for every category somewhere on the page using get_category_feed_link() function.

Edit:

Some feed readers (Chrome’s RSS feed Reader) get feeds from sites header. In this case you can get them to display feed by adding link directly to header.php inside the <head>. Link could be formatted something like this:

<link rel="alternate" type="application/rss+xml" title="Category1 feed" href="https://wordpress.stackexchange.com/questions/176718/<?php echo get_category_feed_link( get_cat_ID("category1' ) ); ?>" /> 

Leave a Comment