0

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
  • Note that you need a return $result; after the return 20; to cover custom pagination values. Otherwise changing the pagination amount won't work. – guidod Jul 4 '17 at 21:26
0

You need upload_per_page:

add_filter( 'get_user_option_edit_upload_per_page', 'my_edit_per_page', 10, 3 );
  • 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 '14 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 '14 at 17:05
  • Interesting. Thank you for the response, clarification...and honesty :) – codeview May 8 '14 at 20:47
  • 1
    Note that the original poster's functin needs a return $result; after the return 20; to cover custom pagination values. Otherwise changing the pagination amount won't work. – guidod just now edit – guidod Jul 4 '17 at 21:26
0

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.

0

Since 2.9.0 version of wordpress the right way to change default screen option value for media items per page (in media library) is as follows:

function my_edit_media_per_page(){
    $media_per_page = 200; //or whatever you want
    return $media_per_page;
}

add_filter( 'upload_per_page', 'my_edit_media_per_page', 10, 3 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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