I’m trying to implement a custom RSS feed that is formatted for podcasting and pulls in the audio file from an Advanced Custom Field. Basically I’ve been working off of the example provided here: https://css-tricks.com/roll-simple-wordpress-podcast-plugin/

My plugin looks like this:

// add a custom RSS feed
function podcast_rss(){
    add_feed('podcast', 'run_podcast_rss');
}
add_action('init', 'podcast_rss');

function run_podcast_rss(){
    require_once( dirname( __FILE__ ) . '/feed-template.php' );
}

This seems pretty straightforward, but when I navigate in my browser to my new feed URL (http://example.com/feed/podcast/) The browser tries to download a file. In Google Chrome, the console shows

Resource interpreted as Document but transferred with MIME type application/octet-stream: "http://example.com/feed/podcast/".

While in Firefox, when it attempts to download the file, it tells me it’s a DMS file.

I’ve tried clearing cache, checking for errors in the code, checking .htaccess for odd settings, setting headers; nothing seems to have an effect. In fact, I can comment out the require_once line and simply try to echo plain text. It still forces a download. I’ve put this on a different server and it behaves the same.

I have a feeling it’s something simple but I’m out of ideas. Any help?

2 Answers
2

You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.

function run_podcast_rss(){
    header( 'Content-Type: application/rss+xml; charset=" . get_option( "blog_charset' ), true );
    require_once( dirname( __FILE__ ) . '/feed-template.php' );
}

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *