Skip to content

Instantly share code, notes, and snippets.

@tribulant
Last active January 9, 2023 20:50
Show Gist options
  • Save tribulant/a33b9c56ececec572cdaa1298d2a056c to your computer and use it in GitHub Desktop.
Save tribulant/a33b9c56ececec572cdaa1298d2a056c to your computer and use it in GitHub Desktop.
WordPress upload_mimes filter hook example
// Add this to the functions.php file of your WordPress theme
// It filters the mime types using the upload_mimes filter hook
// Add as many keys/values to the $mimes Array as needed
function my_custom_upload_mimes($mimes = array()) {
// Add a key and value for the CSV file type
$mimes['csv'] = "text/csv";
return $mimes;
}
add_filter('upload_mimes', 'my_custom_upload_mimes');
@wunc
Copy link

wunc commented Jan 9, 2023

Just leaving a note here for the Googlers: Since 'upload_mimes' is a filter, not a hook, it should be called via:

add_filter('upload_mimes', 'my_custom_upload_mimes');

@tribulant
Copy link
Author

Thank you @wunc, you are indeed correct =). We're the new owners and did not know about this page. We have modified it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment