Skip to content

Instantly share code, notes, and snippets.

@avillegasn
Created September 29, 2016 07:18
Show Gist options
  • Save avillegasn/9d2328c06dfad61c9891731f64d3b97c to your computer and use it in GitHub Desktop.
Save avillegasn/9d2328c06dfad61c9891731f64d3b97c to your computer and use it in GitHub Desktop.
How to allow uploading additional file extensions in WordPress
<?php
add_filter( 'upload_mimes', 'my_myme_types', 1, 1 );
function my_myme_types( $mime_types ) {
$mime_types['svg'] = 'image/svg+xml'; // Adding .svg extension
$mime_types['json'] = 'application/json'; // Adding .json extension
unset( $mime_types['xls'] ); // Remove .xls extension
unset( $mime_types['xlsx'] ); // Remove .xlsx extension
return $mime_types;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment