Quantcast
Channel: WordPress Experts
Viewing all articles
Browse latest Browse all 33

How to add .PDF Support to the WordPress Media Manager!

$
0
0

.pdf supportBy default, the built-in WordPress media manager allows you to filter media by three types: images, audio and video. But if you work a lot with .PDF files, you may need to add an option to filter .PDF files from the media manager. Here is a simple code snippet to do it.

To add .PDF support to the WordPress Media Manager you have to simply paste this code into your functions.php file. Save the file, and you’re done.

function 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>(%s)</span>', 'PDFs <span>(%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' );

Note that this code snippet can be used for other file types as well as .swf, .avi, .mov, etc.

Thanks to WP Tuts for the nice code snippets!

The post How to add .PDF Support to the WordPress Media Manager! appeared first on WordPress Experts.


Viewing all articles
Browse latest Browse all 33

Trending Articles