I suspect the world would be better if that percentage were even greater.
Enclosures in the new WordPress 1.5
Well, there is some support for enclosures right out of the box in the new release of WordPress, but it could still handle a bit of help. The way I hacked this into the old version was to insert two special custom fields and then wire the templates to scan for these and output the right bits of HTML and RSS when each post was printed.
WordPress 1.5 handles things a bit differently: it will scan the post for links to urls which appear to be audio files, and then inserts a custom enclosure
field in the database with the url, size and type included as a string. But since it already thinks that the URL is linked in the post, it does nothing to make the link stand out in any way.
When I updated from 1.2, I converted each of my custom fields into a format which was compatible with the new scheme, but I was then left with a dilemma: go back and patch the text of all 52 entries so that it included a link (ugly) or go ahead and modify the templates to include a customized link. I chose the latter. I found out with a bit of work that code that looks like the following works. I include it just after any template emits the_content
for a post.
[php]
$encs = get_enclosed($post_ID) ;
if ($encs) {
echo ‘
‘;
}[/php]
Nothing too exciting, but might prove useful to you in your work.
Comments
Comment from Brian R.
Time 2/21/2005 at 3:41 pm
How could we get this code to repeate itself so it creates a list of all the enclosures (thus the podcasts) on a site? A audio archive page of sorts.
Editor’s note: I’ve got a simple hack that finds all the enclosures and puts a list of the five most recent entries that contain enclosures that I use to generate the sidebar you can now see on my site. It’s pretty straightforward, I’ll post it in the next day or two.
Comment from Yvonne
Time 4/8/2005 at 11:42 am
Can you tell me what files i need to edit and add the code to?
Thanks.
Editor’s note: I added the code to index.php, in wp-content/themes/brainwagon (brainwagon is, predictably, the name of my theme).
Pingback from Blogging Pro » WordPress Hack: Enclosures Wordpress 1.5
Time 2/19/2005 at 7:40 pm
[…] es WordPress 1.5 Saturday February 19th 2005, 7:35 pm Filed under WordPress Hacks Brainwagon talks about a hack he uses in WordPress 1.5 to make his Podcast links stand out better […]