2

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?

  • What is the content of that file? – fuxia Mar 22 '16 at 21:54
  • If I just echo a string, the file contains the string. If I require_once that template file, it will usually throw an error into the file. For example, if I comment out a part like /* ... */ it errors out on the start of the comment. – mrfolkblues Mar 23 '16 at 0:12
  • Did you check the line endings in that file? – fuxia Mar 23 '16 at 2:42
  • The file is not being FTPd; it's running on a Vagrant/VirtualBox server on my machine and still has this behavior. – mrfolkblues Mar 24 '16 at 1:41
1

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' );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.