In this tutorial I will show you a simple way to add an mp3 player in your blog posts using shortcodes.
For the start I chose an open source mp3 player that can be downloaded from here. The swf file, from this player, must be uploaded in the same directory with your default wordpress theme (Ex. /wp-content/theme-name/).
Add this piece of code in your functions.php file:
Add an mp3 player in your blog post
In this tutorial I will show you a simple way to add an mp3 player in your blog posts using shortcodes.
For the start I chose an open source mp3 player that can be downloaded from here. The swf file, from this player, must be uploaded in the same directory with your default wordpress theme (Ex. /wp-content/theme-name/).
Add this piece of code in your functions.php file:
function show_player($atts) { extract(shortcode_atts(array( 'path' => '', 'width' => '200', 'height' => '20' ), $atts)); return '<object type="application/x-shockwave-flash" data="wp-content/themes/theme-name/player_mp3.swf" width="'.$width.'" height="'.$height.'"> <param name="movie"; value="player_mp3.swf"> <param name="FlashVars" value="mp3='.$path.'"> </object>'; } add_shortcode('mp3', 'show_player');Next, if you want to add the player in your blog post you can simply add this shortcode anywhere in your page:
Or if you want to customize the size of your player you can add:
It’ s that
simple!