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 own
remove_shortcode('audio'); add_shortcode('audio', 'my_audio_shortcode'); function my_audio_shortcode($args) { //TODO: Insert your own version of the shortcode }
-
Use the
wp_audio_shortcode_override
filter hook to overrideadd_filter('wp_audio_shortcode_override', 'my_audio_shortcode'); function my_audio_shortcode($args) { //TODO: Insert your own version of the shortcode }