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.
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
// 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 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',
Just add your desired post_mime_types in above code and you are done.
You might be a photographer or or run a photography blog. Then it is obvious that you want to give credit to all photographers. In WordPress you can do this easily. You just need to add a new tag or taxonomy like “Tag Photographer” and tag the name after uploading the image. Lets see how we can do this.
First of all we need to create a taxonomy for the attachment post type, which is WP media post type.
$labels = array(
'name' => 'Tag Photographers ',
'singular_name' => 'Tag Photographer',
'search_items' => 'Search Photographers',
'all_items' => 'All Photographers',
'parent_item' => 'Parent Photographer',
'parent_item_colon' => 'Parent Photographer:',
'edit_item' => 'Edit Photographer',
'update_item' => 'Update Photographer',
'add_new_item' => 'Add New Photographer',
'new_item_name' => 'New Photographer Name',
'menu_name' => 'Tag Photographer',
$args = array(
‘hierarchical’ => false,
‘labels’ => $labels,
‘show_ui’ => true,
‘show_admin_column’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘my-photographers’ ),
register_taxonomy( ‘my-photographers’, array( ‘attachment’ ), $args );
add_action( ‘init’, ‘my_custom_taxonomies_photographer’ );
Just add the code in your theme’s functions.php file and now go to media list and try to edit a media. You will see the tag box to tag photographer.