I'm using the following code to add new sorting options to my Media Library:

function modify_post_mime_types( $post_mime_types ) {

    $post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) );
    $post_mime_types['application/vnd.openxmlformats-officedocument.presentationml.presentation'] = array( __( 'Powerpoints' ), __( 'Manage Powerpoints' ), _n_noop( 'Powerpoints <span class="count">(%s)</span>', 'Powerpoints <span class="count">(%s)</span>' ) );
    $post_mime_types['application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document'] = array( __( 'Documents' ), __( 'Manage Documents' ), _n_noop( 'Documents <span class="count">(%s)</span>', 'Documents <span class="count">(%s)</span>' ) );

    return $post_mime_types;


add_filter( 'post_mime_types', 'modify_post_mime_types' );

Which appears to be working great for the JavaScript-enabled "Grid" mode:

PDFs Grid

However, in the "List" mode, clicking on the entries shows all the extensions/files (even though it is counting them properly) as shown:

PDFs List

Here's the URL it is redirecting to for the PDFs:


If I try with the standard Wordpress "Images" filter, it indeed works. Here's the URL it gives for that:


I'm thinking this is perhaps a Wordpress bug, but just making sure if anybody knows anything here.

  • 1
    I have a decent workaround here: wordpress.stackexchange.com/a/170471/34438
    – kitchin
    Commented Dec 7, 2014 at 1:43
  • @kitchin Sorry, I can't comment on that yet, so hopefully you get this. For some reason it doesn't look like it is getting all the files. Just as an example, it says PDFs (10), but when I filter, it's only returning the same 4 files. The "Grid" mode returns the proper amount. It doesn't seem to be a file naming issue or anything like that.
    – Drath
    Commented Dec 9, 2014 at 17:28

1 Answer 1


The problem lies in the attachment-filter= URL parameter. The slash between application/pdf (or else) is being escaped twice. When you replace the %252F with a slash or %2F the filter will work.

The first escaping (/ becomes %2F) happens when WP is building the selectbox containing the mime types. The second one (%2F becomes %252F) is performed by the browser.

The easiest Solution would be to manually urldecode the URL param somewhere in PHP:

if ( isset( $_GET['attachment-filter'] ) )
    $_GET['attachment-filter'] = urldecode($_GET['attachment-filter']);

Update: There is a WP core ticket on that issue: https://core.trac.wordpress.org/ticket/30123

Once this gets fixed, the answer above will be obsolete.

  • Do you know where this code could be implemented? Just as a quick hack I added it to functions.php and wp-admin/index.php with no success.
    – Drath
    Commented Nov 14, 2014 at 18:26
  • The code needs to be executed in the backend. Neither of wp-admin/index.php and functions.php is. It chould live either in a plugin or in a mu-plugin. Inside the modify_post_mime_types function above might also be a good place.
    – Jörn Lund
    Commented Nov 15, 2014 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.