• Skip to primary navigation
  • Skip to main content
OsomCode

OsomCode

Awesome code tutorials for WordPress and Genesis

  • Subscribe
  • My account
    • Edit profile
    • Favorites
    • Update credit card
  • Login

Hide download option in WordPress audio block

Discover in this tutorial how to prevent the WordPress audio block from displaying the download button, using code.

Depending on the browser, the audio block displays the option to download the audio file by default.

But in some cases you may prefer to hide it. Luckily, the filter render_block allows you to access the HTML of the block and modify it so that this option is not visible. Let’s see how.

Prevent the WordPress audio block file from downloading

Add the following code at the end of functions.php or in your functionality plugin:

To see this and another 883 code snippets of this website, login or subscribe here.

In this code you use the filter render_block to replace the HTML of the audio block (core/audio). Specifically you modify the value of the HTML property controlsList to disable downloading.

Once applied, all audio blocks will no longer show the option to download the file.

Conclusion

Now you know how to programmatically prevent the audio block of WordPress from showing the option to download the file.

Any questions? Let me know in the comments.

And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉

Block Editor PHP WordPress

To leave read and make questions about this code, you can login or register.

  • About OsomCode
  • FAQ
  • Contact

Legal Notice · Privacy Policy · Cookie Policy · Terms and conditions
Copyright © 2023

Lost your password?