«

A little WordPress plugin for adding audio players to posts

 

I have a ton of old posts for my songs that don’t have HTML5 audio players. Anyone who wanted to hear the songs would have to click a link and have the browser open a player in a new window…like some sort of cavemen. I probably could have written something to update all of the posts, but I decided to whack together a little bit of JavaScript to auto-magically add the HTML audio player for any link to an mp3 that doesn’t already have a corresponding player.

I then had to figure out how to use the script in my WordPress blog. Manually adding script tags to my theme seemed dirty, so instead I threw together a little WordPress plugin that just adds the script to the pages on the fly.

I was going to add it to the WordPress plugin repository, but that required me figuring out how to use git-svn and I am lazy. I’ll leave that for another day.

If you’d like to take a look at the plugin, here’s the github repo:

https://github.com/gerrard00/addaudioplayers-wp-plugin

If the plugin is working, the following link should be immediately followed by an audio player:

This is just a link to the pickabar theme song.