Change the Default URL for Wordpress RSS feed

88 views Asked by At

My client would like a page on their website with the url of /feed. Unfortunately the default URL for Wordpress's RSS feed is /feed.

Is there any way to just move the rss feed from /feed to /antythingelse so i can use the /feed url. Code for the functions file would be preferred over a plugin.

I've tried disabling the feed, but the /feed url still returns an XML file, and does not allow me to use the /feed url.

1

There are 1 answers

1
G Khandelwal On

To change the default URL of the WordPress RSS feed from /feed to something else, you can use the following code snippet in your theme's functions.php file:

function custom_feed_rewrite_rules($wp_rewrite) {
    $new_feed_url = 'yourcustomfeed'; // Change 'yourcustomfeed' to the desired URL
    $wp_rewrite->feeds = array($new_feed_url => $wp_rewrite->feeds['feed']);
    add_feed($new_feed_url, 'do_feed_rss2');
    }
add_action('init', 'custom_feed_rewrite_rules');

Replace 'yourcustomfeed' with the desired URL segment you want to use for your custom feed. After adding this code to your theme's functions.php file, don't forget to save the file.

Please note that changing the default RSS feed URL might impact existing subscribers and may require updating any links or references to the feed.

After making this change, your custom feed will be accessible at http://yoursite.com/yourcustomfeed. Make sure to test the feed to ensure it's working as expected.