large shade tree

Navigation

Information

Recent Posts

Shade Tree Sites |Building Better Websites

Add pdf Filter to WordPress Media

Here’s a function that will add support to filter for pdf’s (or any other supported file type just change the slug)  in WordPress media.

Add the following to functions.php:

 

function modify_post_mime_types( $post_mime_types ) {

// select the mime type,  ‘application/pdf’

// define an array with the label values

$post_mime_types[‘application/pdf’] = array( __( ‘PDFs’ ), __( ‘Manage PDFs’ ), _n_noop( ‘PDF <span>(%s)</span>’, ‘PDFs <span>(%s)</span>’ ) );

// return the $post_mime_types variable      return $post_mime_types;

}

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

You can do this with any file type that WordPress supports.  Look in wp-includes/functions.php to find supported file types and their slugs.

Source:  WPTuts