Created
December 7, 2023 10:07
-
-
Save mohammadfamo/a6b474515f1575fe06bea170c9a2e225 to your computer and use it in GitHub Desktop.
How to stop multiple songs playing wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function vbt_audio_stop() { | |
wp_enqueue_script( 'jquery' ); | |
?> | |
<script> | |
jQuery(document).ready(function (vbt) { | |
vbt("audio").on("play", function () { | |
vbt("audio") | |
.not(this) | |
.each(function (vbt, t) { | |
t.pause(); | |
}); | |
}); | |
}); | |
</script> | |
<?php } | |
add_action('wp_enqueue_scripts', 'vbt_audio_stop'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment