WordPress Trick: Google MP3 Player Shortcode

Here’s another WordPress shortcode which is quite useful. It piggybacks on Googles excellent Flash-based MP3 player (the one they use in Gmail and so on), makes it easy to embed playable MP3s in your posts. Syntax: [raw][mp3=path/to/filename.mp3][/raw]. Dump this in your functions.php:

function mp3player($attr) {
	$src = str_replace("=", "", $attr[0]);
	return '';
}
add_shortcode('mp3', 'mp3player');

Here’s an example:

[mp3=http://www.speakerbiteme.com/tracks/teach_me_tiger.mp3]

Music by Speaker Bite Me.

Responses to “WordPress Trick: Google MP3 Player Shortcode”

  1. Hi. I have the theme Fauna in wordpress, and I see that you can use your own header. The problem is, I just don’t understand how to change the header picture? Could you help me with that ? (:

  2. Thanks. That’s a pretty useful piece of code.

  3. Y5cafe says:

    Its simple but very useful

  4. mkallis says:

    Would this code work if I put in directly in a template header?

Reply