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