Custom RSS Feed Example
An example plugin to demonstrate the right way to implement a custom RSS feed in WordPress
There are a lot of tutorials floating around the internet that describe how to create a custom RSS feed in WordPress. Most of them have you creating a new page template, copying the code that WordPress uses to generate feeds into the page template, and adding to and modifying the code there.
In addition to all of the duplicated RSS code in the template, and the maintenance burden that creates, most of these tutorials exhibit poor coding practices, security vulnerabilities, and do not make use of core WordPress functionality. Having been frustrated with all of the bad tutorials out there, I decided to do something about it and write my own tutorial showing how to create a custom RSS feed in WordPress the right way.
The complete tutorial can be found at https://philipnewcomer.net/2016/08/creating-custom-feeds-wordpress-right-way/. This repository contains the completed plugin we built in the tutorial.
Feel free to fork it and build something on your own.