How to add ‘class’ attribute into shortcode [audio]?

WordPress allows least three options to manipulate the code to your needs. Use a global variable that you increment with @Jevuska ‘s answer. global $my_audio_player_count; $my_audio_player_count = 0; add_filter( ‘wp_audio_shortcode_class’, ‘wpse221201_audio_shortcode_class’, 1, 1 ); function wpse221201_audio_shortcode_class( $class ) { global $my_audio_player_count; $class .= ‘ my-audio-player-‘.$my_audio_player_count++; return $class; } Remove the built-in shortcode and add your … Read more

Is wp_read_audio_metadata() function deprecated?

wp_read_audio_metadata() is not deprecated. It’s located in /wp-admin/includes/media.php, which is not loaded on the front end, hence the error your’re getting. You are using the function correctly. You can make wp_read_audio_metadata() available by including wp-admin/includes/media.php before calling the function, e.g.: require_once( ABSPATH . ‘wp-admin/includes/media.php’ ); $audio_file_path = get_attached_file( 1821 ); // example attachment ID var_dump( … Read more

How to remove hardcoded characters from playlists?

Inside the shortcode function for playlists, there is this line: do_action( ‘wp_playlist_scripts’, $atts[‘type’], $atts[‘style’] ); Hooked into that is wp_playlist_scripts() which hooks the templates into the footer: add_action( ‘wp_footer’, ‘wp_underscore_playlist_templates’, 0 ); add_action( ‘admin_footer’, ‘wp_underscore_playlist_templates’, 0 ); So if you want to replace the templates, you can hook into wp_playlist_scripts after those hooks have been … Read more

Download button for wp audio player

How to use a custom playlist template: You can overwrite the playlist template with your own template: /** * Remove the native playlist template and load our custom template * @link http://wordpress.stackexchange.com/q/141767/26350 */ add_action( ‘wp_playlist_scripts’, ‘wpse_141767_wp_playlist_scripts’ ); function wpse_141767_wp_playlist_scripts() { remove_action( ‘wp_footer’, ‘wp_underscore_playlist_templates’, 0 ); add_action( ‘wp_footer’, ‘wpse_141767_wp_underscore_playlist_templates’, 0 ); } where our modified template … Read more

How to get the number of times an audio file has been played

Yes, the play event fires on the <audio> element, so you could target it eg $(‘audio.wp-audio-shortcode’).on(‘play’, function (event) { //etc });. A number of other events are also available, eg ended, playing, pause. Here’s some code I’m trialing at the moment that may help you (in “functions.php”): add_action( ‘wp_footer’, function () { ?> <script> jQuery(document).ready(function() … Read more

Replace audio/video enclosure with player?

I believe part of what you’re looking for is the WP_Embed class defined in wp-includes/media.php. It implements a framework for automatically replacing urls with the output of embed handlers. I’m afraid you’ll have to do the deeper research yourself (this was apparently introduces in 2.9.0, so documentation might still be thin). I doubt WordPress core … Read more

Making audio playlist with external audio files?

Playlist shortcode with external audio or video files Here I explain how you can implement idea 3 in my other answer, where we use the following shortcode structure: [wpse_playlist type=”” current=”” style=”” tracklist=”” tracknumbers=”” images=”” artist=””] [wpse_trac src=”” title=”” type=”” caption=”” description=”” image=”” meta_artist=”” meta_album=”” meta_genre=”” meta_length_formatted=”” image_src=”” image_width=”” image_height=”” thumb_src=”” thumb_width=”” thumb_height=””] [wpse_trac src=”” … Read more

Playing Sound In Hidden Tag

I agree with the sentiment in the comments above — this can be pretty annoying. We can only hope you give the user the option to turn the music off. However…  Run code snippetExpand snippet The css hides the audio element, and the autoplay=”true” plays it automatically.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)