Two methods to insert music into WordPress articles

Source: Internet
Author: User
Tags file url

Method 1:

1. Add: Copy the following code to functions. php (note that it is in the php loop), and then download the example

The code is as follows: Copy code

Function mp3player ($ atts, $ content = null ){
Extract (export code_atts (array ("auto" => '0'), $ atts ));
Return '<embed src = "'. get_bloginfo (" template_url "). '/mp3player.swf? Url = '. $ content. '& amp; autoplay = '. $ auto. '"type =" application/x-shockwave-flash "wmode =" transparent "allowscriptaccess =" always "width =" 400 "height =" 30 "/> ';
}  
Add_playback code ('mp3', 'mp3player ');

2. Use: When writing an article, insert the following format code in "HTML (text) mode".

The code is as follows: Copy code

[Mp3 auto = "0" vol = "60"] MP3 file URL [/mp3]

The above code: auto: whether to play automatically (0 or 1); vol: volume (1 ~ 100)

Effect:

Method 2:

1. Copy the following code to functions. php (note that it is in the php loop), and then download the example.

The code is as follows: Copy code

/** Add flash player */
Function myplayer ($ atts, $ content = null ){
Extract (export code_atts (array ("auto" => 'no', "loop" => 'no'), $ atts ));
Return '<embed src = "'. get_bloginfo (" template_url "). '/player.swf? SoundFile = '. $ content. '& bg = 0 xeeeeee & leftbg = Mirror & lefticon = 0 xFFFFFF & rightbg = Mirror & rightbghover = 0xaf2910 & righticon = 0 xffffffff & expires = 0 xFFFFFF & text = 0x666666 & slider = 0x666666 & track = 0 xFFFFFF & border = 0x666666 & loader = 0x9FFFB8 & loop = '. $ loop. '& autostart = '. $ auto. '"type =" application/x-shockwave-flash "wmode =" transparent "allowscriptaccess =" always "width =" 290 "height =" 30 "/> ';
}  
Add_audio code ('Music', 'myplayer ');

2. Use: When writing an article, insert the following format code in "HTML (text) mode".

The code is as follows: Copy code

[Music] MP3 file URL [/music]

You can set the color of the player on your own. You can modify the color code on the top and try it on your own.

The effect is as follows:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.