Have you ever wanted to make a song play automatically on the home page or another page of a WordPress website, but weren’t quite sure how to get the built in code to do it? No worries! We have the code snippet below that can make the song auto play.
Auto play songs need to be used very sparingly and special attention needs to be paid to whether the music compliments the content or takes away or even worse annoys and chases away guests. A good way to figure this out is do a field test with 2 or 3 good friends to see if your site becomes annoying on the six or seventh time visiting the home page.
To add audio to a WordPress page or post, just click the “Add Media” button above the text box and select the audio file from where it may be at on your Desktop or another folder on your computer. Insert the song into the page and make sure you are on the “Text” editor side, not the “Visual” editor. You’ll know the difference if you see a visual cue for an audio file instead of a piece of code that executes the audio file and adds controls.
The WordPress audio clip code looks like this:
The WordPress audio clip auto play code looks like this:
Notice that we added the function autoplay=”y” to turn the auto play functionality on for the audio clip.
Now use it sparingly, as there are definitely issues to be concerned about when having music on a website. For example, what if someone has a really powerful stereo hooked up to their computer and it is turned up high but there is no sound coming out. If they visit your website like that, they may be blown away not expecting music to play and it may force them to close out your site and not return possibly.
Monitoring a websites traffic before and after a audio clip auto play is important to determine what impact, if any the automatic music playing is having on visitors sticking around on the site.
Check out the example of this audio clip auto play function on Landon’s Legacy website (a great foundation!)
How did you use the audio clip auto play function to spruce up your site? Tell us in the comments ->