Change default screen option value for posts per page

Just an addiction to @KrzysiekDróżdż answer.

When viewing a specific post status the url query string variable 'post_status', is set to the name of the status, so you can use $_GET['post_status'] to narrow the effect of @KrzysiekDróżdż code only for pending posts:

function my_edit_per_page( $result, $option, $user ) {
  $status = filter_input( INPUT_GET, 'post_status', FILTER_SANITIZE_STRING );
  if ( $status === 'pending' && (int) $result < 1 )
  return 20; // or whatever you want
}
add_filter( 'get_user_option_edit_post_per_page', 'my_edit_per_page', 10, 3 );  // for posts

Leave a Comment