How to add additional file types in Wordpress

by Matt Heff

This is the simplest way to give yourself complete freedom to put whatever type of file you want up in wordpress, the standard list of files is far to narrow for most sites that are going to be delivery more than just text as content.

Let’s get straight to it!

Allow Additional File types using wp-admin

This method requires that you have access to the file system and can modify the wp-config file, if you are not able to do this then you are better off using a plugin or modify the functions.php file ( more on that below).

Steps to reliever your frustration

  • Navigate to your WordPress installation directory
  • Make a copy of your wp-admin.php ( just incase)
  • Open wp-admin.php in any editor
  • Add this to the file
define ( ‘ALLOW_UNFILTERED_UPLOADS’ , true );
  • Now save the file into your WordPress directory, flushing the caches may help it take effect quicker.

* Note: Some plugins / themes may have their own file filters in place, but this is guaranteed to work with the core media library.

Allow Additional File types using functions.php / upload_mimes filter.

If you dont have direct access to the file system then this may work for you

  • Navigate to via Appearance -> Theme File Editor
  • Select the functions.php file
  • Add the following code
function my_mime_types($mimes) {
    $mime_types = array(
        'json'     => 'application/json',
    );
    return $mimes;
   }
add_filter('upload_mimes', 'my_mime_types');

define( 'ALLOW_UNFILTERED_UPLOADS', true );  // this is the same setting as we has in wp-config.php in the previous section
  • Save the modifications to the functions.php and you will be good to go!

That is pretty much it for this entry, below is a list of file types you may be interested in these are mostly there to help me catch interest from specific searches for those file types.

I hope this has been helpful for you.

Types of files to allow in WordPress

Documents & Sheets

  • .docx & .doc (Microsoft Word Document)
  • .rtf (Rich Text Format File)
  • .tex (LaTeX Source Document)
  • .log (Log File)
  • .pdf (Adobe: Portable Document Format)
  • .xlsx, .Xls (Microsoft Excel Document)
  • .pptx, .ppt, .pps, .ppsx (Microsoft Powerpoint File)
  • .odt (OpenDocument Text Documet)

Audio Files

  • .wav (WAVE Format)
  • .mp3 (MPEG3 Format)
  • .ogg (OGG Multimedia Container)
  • .m4a (Advanced Audio Coding)
  • .aif ( Audio Interchange File Format)
  • .wma ( Windows Media Audio File)

Image Files

  • .jpeg & .jpg (Joint Photography Experts Group)
  • .psd (Adobe Photoshop Document)
  • .png (Portable Network Graphics)
  • .gif (Graphics interchange Product)
  • .ico (Icon File Extension)
  • .obj (Wavefront 3d Object File)
  • .3ds (3D Studio Scene)
  • .tif (Tagged Image File)
  • .tiff (Tagged Image File Format)

Video Files

  • .wmv (Windows Media Video)
  • .rm (RealMedia File)
  • .flv (Flash Video File)
  • .mpg (MPEG Video)
  • .mp4 (MPEG4 Format)
  • .m4v (Video Container Format)
  • .mov (Quick Time Format)
  • .avi (Audio Video Interleaved Format)
  • .ogv (OGG Vorbis Video Encoding)
  • .3gp (Mobile Phone Video)

Data Files

  • .CSV Comma-Separated Values File
  • .DAT Data File
  • .GED GEDCOM Genealogy Data File
  • .JSON JavaScript Object Notation File
  • .KEY Apple Keynote Presentation
  • .KEYCHAIN Mac OS X Keychain File
  • .PPT Microsoft PowerPoint Presentation (Legacy)
  • .PPTX Microsoft PowerPoint Presentation
  • .SDF Standard Data File
  • .TAR Consolidated Unix File Archive
  • .VCF vCard File
  • .XML XML File

Related Posts