Skip to content

Instantly share code, notes, and snippets.

@michaelbourne
Last active January 19, 2024 16:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michaelbourne/905b2ca43f51eb6dd746acf1c4a47884 to your computer and use it in GitHub Desktop.
Save michaelbourne/905b2ca43f51eb6dd746acf1c4a47884 to your computer and use it in GitHub Desktop.
Add support for WOFF and WOFF2 file uploads in WordPress
<?php
// The following code goes in your functions.php file of a Child Theme
function custom_font_mime_types($mimes = array()) {
$mimes['woff'] = 'application/x-font-woff';
$mimes['woff2'] = 'application/x-font-woff2';
// Depending on your server setup, you may need to use these instead:
//$mimes['woff'] = 'font/woff';
//$mimes['woff2'] = 'font/woff2';
return $mimes;
}
add_filter('upload_mimes', 'custom_font_mime_types');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment