How to mute videos in WordPress

Has it ever happened to you on a website where there are several autoplay videos that start to play all at once…

It happens more than you think.

For example, you put a video with autoplay sound in the background in the sidebar, which nothing interferes with the front page of your website but it turns out that on a particular page or entry you have another video with sound, which also plays automatically, and that becomes a crazy symphony. I tell you that this is just an example, but it happens more than you think and it is easy to fix.

How to mute videos individually

If you have uploaded a video to your site and want to mute it, go to the video settings, check the “Mute” box and save the changes.

video example with muted setting option

How to mute all videos automatically and by default

Now let’s make sure that no video with autoplay has sound by default. In this case, the solution is to mute the WordPress player altogether with a bit of code, this one:

/* Mute all videos by default */
function wphelp_mute_all_videos() {
<script type="text/javascript">
[]'video')).forEach(function(audio) {
audio.muted = true;
# Footer
add_action( 'wp_footer', 'wphelp_mute_all_videos' );Code language: PHP (php)

With this bit of JavaScript your videos will still play automatically (or not) but always muted by default, and silence will reign on your website. Of course, this mutes all videos on the web, no exceptions, so use it only if you are clear that this is EXACTLY what you want.

Where do I add this code?

How and where to paste PHP, JS, CSS codes and functions you find around in WordPress

How useful was this post?

Click on a smiley to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top