New! Unlimited audio, video & web asset downloads! Unlimited audio, video & web assets! From $16.50/m
  1. Code
  2. WordPress

Quick Tip: Add Extra Media Type Filters to the WordPress Media Manager


By default the WordPress Media Manager allows you to filter media by three types only; Images, Video and Audio.

The site I am currently developing will use a lot of PDF attachments, so I wanted to add PDF filtering to the media manager.

I found that extra file type filtering can be added to the media manager using a simple filter hook.

Example; Adding PDFs

To achieve this we are going to utilise the 'post_mime_types' filter.

Within our function we will select the file type using the mime type slug, the slug for PDFs is 'application/pdf'

Then we define an array that will contain the text labels for the file type.

That's it! The option to filter out PDF files now appears in your Media Manager (once you have at least one PDF in your library)

Other File Types

You can do this with any files that WordPress supports. Supported file types are defined by WordPress in wp-includes/functions.php

The default supported file types are defined within the get_allowed_mime_types() function.

To find the slug of the file type you're looking for just search for 'get_allowed_mime_types()' in wp-includes/functions.php

The number of file types that WordPress supports is extensive so I won't list them all, but here's a small sample:

As you can see the see the slug for Flash .swf files would be 'application/x-shockwave-flash'.

Do you have any tips on file types in WordPress' media manager? Share them in the comments below!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.