I am trying to add CORS (http://enable-cors.org/) support to an RSS2 feed within a custom Wordpress theme. I have tried the following, all to no avail:
Following the instructions on https://web.archive.org/web/20140314152828/http://bowdenweb.com:80/wp/2011/05/how-to-enable-cors-in-wordpress.html, I attempted to modify the theme's header.php file and add the following code to it:
header("Access-Control-Allow-Origin: *");
This was successful in adding the CORS header to the Wordpress posts, but not to the RSS2 feed.
Then, I attempted to use the "Plugin API / Action Reference", i.e. the
add_action
function (http://codex.wordpress.org/Plugin_API/Action_Reference).I added the following code to header.php:
function add_cors_headers() { header("Access-Control-Allow-Origin: *"); } add_action('rss2_head','add_cors_headers');
Again, no success. Now I am at a dead end. Any ideas?