RSS enclosures not working for custom post types (3 posts)

  1. cfgmiller
    Posted 4 years ago #

    I'm having trouble getting a podcast working that's running from the feed for a custom post type. The feed works, but there are no enclosures and therefore it's not recognised as a podcast.

    Things that work fine:
    - enclosures on normal posts
    - RSS feed for custom post type, at [site]/feed/?post_type=podcast
    (feed works fine, displays link to audio files - no problems there)

    WordPress' automatic recognition of MP3 links doesn't seem to be working for this custom post type...
    Without the bother of creating a new post type to test, any suggestions about how I get to the bottom of this?

    Here's where I've got to so far...
    rss_enclosure() uses data from get_post_custom().
    Taking a look at this, I can see that my custom post type does not have an enclosure field in the meta data...
    - Any ideas why?


  2. smajda
    Posted 3 years ago #

    You have to call do_enclose for the post:

    function my_do_enclose($id) {
    do_enclose(get_post_field('post_content', $id), $id);
    add_action('post_updated', 'my_do_enclose');

  3. smajda
    Posted 3 years ago #

    Actually, you should probably check for post_type or else you'll be doing this twice for regular posts. In my case, I have a 'podcast' post_type:

    function podcast_do_enclose($id) {
        $post = get_post($id);
        if ($post->post_type == 'podcast') {
          do_enclose($post->post_content, $id);
    add_action('post_updated', 'podcast_do_enclose');

Topic Closed

This topic has been closed to new replies.

About this Topic