[wp-hackers] Audio RSS enclosure problem

Bryan Harley bryanharley at gmail.com
Sun Mar 20 06:41:54 UTC 2011


Here's what I ended up doing, though I'm open to a more elegant
solution!  Opened /wp-includes/feed-rss2.php.  Replaced the enclosure
tag with:

<?php $mp3s = get_children('numberposts=-1&post_type=attachment&post_mime_type=audio&post_parent='.$post->ID);
if (!empty($mp3s)) : ?>

<?php foreach($mp3s as $mp3) : ?>

<?php $mp3url = $mp3->guid; $mp3header = get_headers($mp3url, 1);
$mp3size = $mp3header['Content-Length']; ?>

<enclosure url="<?php echo $mp3url; ?>" length="<?php echo $mp3size;
?>" type="audio/mpeg" />

<?php endforeach; ?>
<?php endif; ?>



On Sat, Mar 19, 2011 at 9:40 PM, Bryan Harley <bryanharley at gmail.com> wrote:
> Thanks Chip, but I need to get the attachment ID dynamically, that's
> why I'm using get_children.
>
>
> On Sat, Mar 19, 2011 at 9:34 PM, Chip Bennett <chip at chipbennett.net> wrote:
>> Could you use the "audio" Post-Format type, and then in your "audio"
>> Post-Format type-specific loop output, pull the attachment link into the
>> Post output automatically, using e.g. get_attachment_link()?
>>
>> http://codex.wordpress.org/Function_Reference/get_attachment_link
>>
>> <http://codex.wordpress.org/Function_Reference/get_attachment_link>Chip
>>
>> On Sat, Mar 19, 2011 at 11:23 PM, Bryan Harley <bryanharley at gmail.com>wrote:
>>
>>> Thanks Christopher.  I followed the steps here:
>>>
>>> http://www.wprecipes.com/how-to-automatically-insert-content-after-each-post
>>>
>>> And while the link to the audio was successfully added, it didn't
>>> trigger the audio enclosure for some reason.
>>>
>>>
>>>
>>> On Sat, Mar 19, 2011 at 4:25 PM, Christopher Ross <cross at thisismyurl.com>
>>> wrote:
>>> > Bryan, using the publish hook you could add the link directly to the post
>>> with the $content value. This would accomplish both the automation you're
>>> seeking and also trigger the audio enclosure.
>>> >
>>> >
>>> >
>>> > On 2011-03-19, at 8:21 PM, Bryan Harley wrote:
>>> >
>>> >> So I have a client with a website for their podcast. To make it easy,
>>> >> I just have them upload their audio file to a post and then use
>>> >> get_children to grab the audio attachment and display it where I want
>>> >> on the page.   That way they don't have to deal with custom fields or
>>> >> inserting code or anything like that.
>>> >>
>>> >> Only problem... WP will only auto-create the audio enclosure in the
>>> >> RSS feed if you have the mp3 linked from the post content.  Since I'm
>>> >> using attachments, it won't auto-create the enclosure.  Any ideas?
>>> >> _______________________________________________
>>> >> wp-hackers mailing list
>>> >> wp-hackers at lists.automattic.com
>>> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>> >
>>> >
>>> >
>>> > __
>>> >
>>> > Christopher Ross
>>> > Online Portfolio - http://christopherross.ca
>>> > Personal Blog - http://thisismyurl.com
>>> >
>>> > Fredericton - 506.238.4661
>>> > San Diego   - 858.201.4912
>>> >
>>> > _______________________________________________
>>> > wp-hackers mailing list
>>> > wp-hackers at lists.automattic.com
>>> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>>> >
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>


More information about the wp-hackers mailing list