Support

Account

Home Forums General Issues Add Audio to RSS XML

Solving

Add Audio to RSS XML

  • I created a custom meta box called Podcasts where a user can upload a podcast. This custom meta box is only available on a custom post type called Podcasts. I am now trying to figure out how to connect to iTunes. I need to make sure that the audio appears in the RSS feed for the custom post type.

    I put the following in my functions.php:

    //Add Audio to Podcast Feed
    function add_audio_to_feed($content) {
        if(is_feed()) {
            $post_id = get_the_ID();
            $output .= '<audio controls> <source src="' . get_post_meta($post_id, 'podcast', true) . '" type="audio/mpeg"></audio>';
            $content = $content.$output;
        }
        return $content;
    }
    add_filter('the_content','add_audio_to_feed');

    This outputs this to the XML:
    <audio controls> <source src="" type="audio/mpeg"></audio>

    Why is the source blank? In the archive template for my custom post type, the following code works just fine…

    <audio controls>
    <source src="<?php the_field('podcast'); ?>" type="audio/mpeg">
    Your browser does not support the audio element.
    </audio>

    Any help would be much appreciated.

  • I’ve also tried this:

    //Add Audio to Podcast Feed
    function add_audio_to_feed($content) {
        if(is_feed()) {
            $post_id = get_the_ID();
            $output .= '<audio controls> <source src="' . the_field('podcast') . '" type="audio/mpeg"></audio>';
            $content = $content.$output;
        }
        return $content;
    }
    add_filter('the_content','add_audio_to_feed');
  • Hi!
    Did you find a solution to the problem?

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Add Audio to RSS XML’ is closed to new replies.