Are you interested in incorporating audio files into your WordPress website? As a versatile content management system, WordPress has the inherent ability to manage audio files. Nevertheless, some novice users may not be familiar with this feature. This article will provide a step-by-step guide on how to add audio files and generate playlists in WordPress.
Audio file formats that are compatible with WordPress
The audio files in WordPress are embedded using the HTML5 audio tag, which is compatible with most modern devices and works exceptionally well for mobile devices. The HTML5 audio tag supports various file formats, including MP3, OGG, and WAV. Among these formats, MP3 is the most widely used and supported, and we highly recommend using it whenever feasible.
How to Add a Single Audio File in WordPress
It is effortless to add a single audio file or music track to any WordPress post or page. All you need to do is click on the “add media” button on the post edit screen.
Once you click on it, a media uploader popup will appear on your screen. You can select and upload your audio file by clicking on the “upload file” button. After the file is uploaded, click on the “insert into post” button.
WordPress will insert your audio file into the post. If you are using the visual post editor, you will see the file embedded in your post. If you are using the text editor, you will see the audio shortcode.
You can continue editing your post or save and publish it. Once published, you can preview your post, and you will see your audio file embedded in it.
Alternatively, you can upload the file to the media library and copy the file URL. Then, paste it into the visual editor, and WordPress will automatically embed the URL for you. This is similar to how you embed videos in WordPress by pasting the URL of a YouTube video, and WordPress automatically embeds it.
How to Add an Audio Playlist in WordPress
Adding audio playlists to your WordPress posts is just as easy as creating image galleries. To get started, click on the add media button and upload your audio files. After uploading, select the files you want to include in the playlist and click on the create new playlist link in the left-hand column.
To customize your playlist, you can rearrange the songs by dragging and dropping them. You can also choose to display the track name, artist name, and image by enabling these options. This information is automatically displayed by WordPress, as it is embedded in your MP3 file’s IDT meta tags.
Once you have finished customizing your playlist, click on the insert audio playlist button. Your playlist will be added to your post, and you can preview it in the visual editor. Save your post, and your audio playlist is ready to go!
Modifying Meta Data of Audio Files in WordPress
In WordPress, it is possible to edit the meta information of audio files. Although WordPress can automatically retrieve the meta information from your MP3 file, you can modify it if the file lacks meta information or if you want to make changes.
To access the media uploader, click on the Add Media button. You can either upload your audio file or select it from the Media Library if it has already been uploaded.
After selecting the audio file, you will see the attachment details column on the right. Here, you can add the track title, artist name, album name, caption, and a brief description for the track. This information will be displayed on single attachment pages and playlists.
If the audio file that you have uploaded contains an embedded image intended to be used as an album cover, WordPress will automatically extract and store it in your media library. This image will then be utilized when the track is added to a playlist.
In case your audio file does not have a cover image, you can still add one by editing the file in WordPress. To do this, navigate to Media » Library, select the file you wish to edit, and click on the edit link located below it.
If you are browsing the media library in grid view, clicking on the audio file will trigger a popup window. To edit the file, simply click on the “Edit more details” link located at the bottom of the popup.
Upon reaching the edit media page, you will have the ability to modify the meta information of your audio file and upload a featured image. This image will be utilized when the audio file is included in a playlist.
To add audio files and playlists to sidebar widgets, follow these steps
WordPress does not embed audio file URLs automatically. To enable automatic embedding for text widgets and shortcodes, you need to add the following code to your theme’s functions.php file or a site-specific plugin.
add_filter( ‘widget_text’, array( $wp_embed, ‘run_shortcode’), 8 );
add_filter( ‘widget_text’, array( $wp_embed, ‘autoembed’), 8 );
add_filter( ‘widget_text’, ‘do_shortcode’);
By default, WordPress does not automatically embed audio file URLs. To enable automatic embedding for text widgets and shortcodes, you can add the following code to your theme’s functions.php file or a site-specific plugin.
Once enabled, you can upload an audio file to the media library and copy its URL. Then, add a text widget to your WordPress sidebar and paste the URL inside it. WordPress will automatically embed the URL into a media player to play your audio file.
To create a playlist, use the shortcode with the IDs of the media files you want to include. First, upload the audio files to the media library by visiting Media » Add New. Then, edit each audio file and find the media file ID below the title field on the Edit Media page.
After obtaining the IDs of the files you wish to include in the playlist, you can utilize the following shortcode:
Remember to substitute the IDs with your own file IDs. This shortcode can be inserted into a text widget. Here is an example of how it appeared on our test website: