Change which type of files you can upload in WordPress

photo credit: <a href="http://www.flickr.com/photos/59939034@N02/5476290862">bs-iv-folie-2</a> via <a href="http://photopin.com">photopin</a> <a href="https://creativecommons.org/licenses/by/2.0/">(license)</a>

by Aaron Reimann

September 21, 2012

We recently had a client that needed to be able to upload a “vCard” and they were not able to do so. That is because WP limits what type of files can be uploaded. By default you can only upload media to the “Media Library”, which makes perfect sense, right? But what if we need to upload PowerPoint, Word documents, etc, well, here is the code that allows you to do that.

Go to the theme’s functions.php file and drop in the code (within the tags that should already be at the top of the file).
[cc lang=”html”]
add_filter(‘upload_mimes’, ‘custom_upload_mimes’);
function custom_upload_mimes ( $existing_mimes=array() ) {
$existing_mimes[‘vcard’] = ‘application/x-vcard’;
$existing_mimes[‘vcf’] = ‘application/x-vcf’;
return $existing_mimes;
}
[/cc]

photo credit: bs-iv-folie-2 via photopin (license)

related posts

Font Awesome icon

How to add a Font Awesome icon as a menu item

I’ve started recording a lot of videos, this being the first, for 48in48 (If you don’t…

A Page Builder Must Have Add-On

Page builders are more common in the WordPress community now than ever.  There has been…

Beaver Builder Visual Hook Guide How To

One of the guys (Bret) showed me this plugin that is on GitHub and I…