Add Extra Media Type Filters to the WordPress Media Manager

Last updated 11 months ago

PHP
//Add Extra Media Type Filters to the WordPress Media Manager

    function hlabs_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 (%s)', 'PDFs (%s)' ) );  
      
        // then we return the $post_mime_types variable  
        return $post_mime_types;  
      
    }  
      
    // Add Filter Hook  
    add_filter( 'post_mime_types', 'hlabs_modify_post_mime_types' );  

All code snippets are licensed GPLv2 or later unless otherwise stated.