Add Custom Media Type Filters in WordPress Media Library

Print View Mobile View

By default only three filters – Images, Video, and Audio – are supported in the WordPress Media Library. If you upload other file types on your blog, following code snippet will allow you to add filters for those as well:

function custom_mime_types( $post_mime_types ) {
        $post_mime_types['application/msword'] = array( __( 'DOCs' ), __( 'Manage DOCs' ), _n_noop( 'DOC <span class="count">(%s)</span>', 'DOC <span class="count">(%s)</span>' ) );
        $post_mime_types['application/vnd.ms-excel'] = array( __( 'XLSs' ), __( 'Manage XLSs' ), _n_noop( 'XLS <span class="count">(%s)</span>', 'XLSs <span class="count">(%s)</span>' ) );
        $post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) );
        $post_mime_types['application/zip'] = array( __( 'ZIPs' ), __( 'Manage ZIPs' ), _n_noop( 'ZIP <span class="count">(%s)</span>', 'ZIPs <span class="count">(%s)</span>' ) );
		
        return $post_mime_types;
}
add_filter( 'post_mime_types', 'custom_mime_types' );

Custom Media Type

Just drop the code in your theme’s functions.php file. The code as it is will add filters for DOCX, XLS, PDF, and ZIP files.

WordPress supports a whole lot more mime types, and you can easily add those to the above code. To see the complete list of supported mime types, open wp-includes/functions.php file and search for get_allowed_mime_types. (via Wptuts+)