Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to remove pagination by changing the default screen option value for posts per page, pages per page and media items per page, in the admin area, to 999. The default value is set to 20. I found the answer I need (I have pasted below from @KrzysiekDróżdż's answer in this question: Change default screen option value for posts per page) but am looking to also add a filter for the media library so it's consistent for all areas of the admin.

function my_edit_per_page( $result, $option, $user ) {
    if ( (int)$result < 1 )
        return 20; // or whatever you want
}
add_filter( 'get_user_option_edit_page_per_page', 'my_edit_per_page', 10, 3 );  // for pages
add_filter( 'get_user_option_edit_post_per_page', 'my_edit_per_page', 10, 3 );  // for posts

I've tried these, to no avail:

add_filter( 'get_user_option_edit_media_per_page', 'my_edit_per_page', 10, 3 );  // for media library
add_filter( 'get_user_option_edit_media_item_per_page', 'my_edit_per_page', 10, 3 );  // for media library
add_filter( 'get_user_option_edit_media_items_per_page', 'my_edit_per_page', 10, 3 );  // for media library
share|improve this question

2 Answers 2

up vote 0 down vote accepted

You need upload_per_page:

add_filter( 'get_user_option_edit_upload_per_page', 'my_edit_per_page', 10, 3 );
share|improve this answer
    
Ah! Thank you. Do you have a reference for how you knew that? My Google searches do not find me any sort of filter listings explaining any of them: get_user_option_edit_page_per_page, get_user_option_edit_post_per_page or get_user_option_edit_upload_per_page –  codeview May 7 at 18:54
    
It's sneakily buried in wp_edit_attachments_query(), which is used by WP_Media_List_Table. But TBH I cheated & just inspected the ID of the screen options field in Firebug ;) –  TheDeadMedic May 8 at 17:05
    
Interesting. Thank you for the response, clarification...and honesty :) –  codeview May 8 at 20:47

Setting the value to 999 will screw up most wordpress hosting, I do not know whether it is PHP or Wordpress but I have tried 500 and it completely wrecks that feature. This is particularly true of images in media library, there seems to be a different setting for grid and list, so you still have access to list but if you select grid again you get a white screen of death. Now I have to go in the backend and try and figure out what field in what table holds the setting.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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