WordPress media manager, by default, allows you to filter media with the three types, say, images, audio and video. But, if in case, you required more and want to add PDF support to it, then here is a simple code snippet for you to do the task. Copy and paste the following snippet into your theme’s functions.php file and you are done.
1 2 3 4 5 6 7 8 9 | modify_post_mime_types( $post_mime_types ) { // select the mime type, here: 'application/pdf' // then we define an array with the label values $post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) ); // then we return the $post_mime_types variable return $post_mime_types; } // Add Filter Hook add_filter( 'post_mime_types', 'modify_post_mime_types' ); |
Snippet Source/Credit: WP Tuts