Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

WordPress Snippet: Add Uploadable File Types

My Documents Shortcode plugin lets you display uploaded attachments. WordPress limits what kinds of files you can upload, but you might need to upload additional types of files. Here’s an example of how to add new file types to the ones that WordPress will allow. In my case, I needed to upload a Keynote slideshow, which had the file extension .key:


About Dougal Campbell

Dougal is a web developer, and a "Developer Emeritus" for the WordPress platform. When he's not coding PHP, Perl, CSS, JavaScript, or whatnot, he spends time with his wife, three children, a dog, and a cat in their Atlanta area home.
This entry was posted in WordPress and tagged , , , , , , , , . Bookmark the permalink.

4 Responses to WordPress Snippet: Add Uploadable File Types

  1. Otto says:

    In 3.5 and beyond, I’d put that on the “mime_types” filter instead of “upload_mimes”, simply because that will ensure the custom mime types are returned by anything calling wp_get_mime_types().

    Also, note that in Multisite setups, even adding the mime type is not enough, the multisite has to be configured to allow the upload of the given extension in the Network settings pages.

  2. Dougal says:

    Thanks for the tip. I’ll keep that in mind when I start working on the next version. Eventually, I’d like to add a settings page to give some control to the user. Also want to get additional file type icons added, with multiple sizes, and in a sprite.

  3. Lin Ai says:

    Thanks for this post; I think it is exactly what I need, but I’m having trouble making it work. My theme options have a place to insert custom scripts, so I put your code in the area that said it would embed in header.php. But I think this must be wrong, because I still get a security error when trying to upload a Keynote. Where should I add the code?

Leave a Reply

%d bloggers like this: