为了给我们的博客文章内容丰富起来,有些时刻我们需要给wordpress的文章内增加一些视频、图片和音乐,而本日引见的wordpress教程是如安在wordpress通太短代码完成美丽的mp3音乐播放器功用!
起首引见第一款播放器的完成要领是将下面代码加入到wordpress主题文件的function.php内
//音乐播放器
function doubanplayer($atts, $content=null){
extract(shortcode_atts(array("auto"=>'0'),$atts));
return '<embed src="'.get_bloginfo("template_url").'/shortcode/doubanplayer.swf?url='.$content.'&autoplay='.$auto.'" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" width="400" height="30">';
}
add_shortcode('music','doubanplayer');
通用音乐播放器
默许不自动播放:[music]http://www.xxx.com/xxx.mp3[/music]
自动播放: [music auto=1]http://www.xxx.com/xxx.mp3[/music]
第二款播放器的完成要领是将下面代码加入到wordpress主题文件的function.php内
//mp3专用播放器
function mp3link($atts, $content=null){
extract(shortcode_atts(array("auto"=>'0',"replay"=>'0',),$atts));
return '<embed src="'.get_bloginfo("template_url").'/shortcode/dewplayer.swf?mp3='.$content.'&autostart='.$auto.'&autoreplay='.$replay.'" wmode="transparent" height="20" width="240" type="application/x-shockwave-flash" />';
}
add_shortcode('mp3','mp3link');
Mp3专用播放器
默许不轮回不自动播放:[mp3]http://www.xxx.com/xxx.mp3[/mp3]
自动播放: [mp3 auto="1"]http://www.xxx.com/xxx.mp3[/mp3]
轮回播放: [mp3 replay="1"]http://www.xxx.com/xxx.mp3[/mp3]
自动及轮回播放:[mp3 auto="1" replay="1"]http://www.xxx.com/xxx.mp3[/mp3]
末了将音乐播放器的swf文件上传到wordpress主题文件夹的shortcode文件内,没有的自建即可!概况如下图
末了小2供应两个播放器swf的下载地点哈
文件下载

评论列表