Add PDF Media Type Filters to WordPress Media Manager

Via:MyTutorialGuru.com

By default in WordPress media manager there are three types of filter exist image, audio and video. One of most common file we upload is PDF format file and it would be nice to have a PDF filter option in your media manager. And you have came to the right place. Lets see how we can add PDF media type filters to WordPress media manager.

wordpress-media-filter

Add the following code to your theme’s functions.php file

function modify_post_mime_types( $post_mime_types )
// select the mime type, here: 'application/pdf'
$post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF (%s)', 'PDFs (%s)' ) );

// then we return the $post_mime_types variable
return $post_mime_types;

// Add Filter Hook
add_filter( ‘post_mime_types’, ‘modify_post_mime_types’ );

Now you can see the PDF filter option in your media manager:

wordpress-media-filter-pdf

WordPress supports tons of file types. Here are some examples:
'pdf' => 'application/pdf',
'swf' => 'application/x-shockwave-flash',
'mov|qt' => 'video/quicktime',
'flv' => 'video/x-flv',
'avi' => 'video/avi',
'divx' => 'video/divx',
'js' => 'application/javascript',

Just add your desired post_mime_types in above code and you are done.

Advertisements

Posted on May 2, 2015, in Uncategorized and tagged , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: