WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to change the default screen option value for posts per page in the wp-admin area when listing posts in pending mode. The default value is set to 20.

Changing the value directly in the Screen Options tab will only affect the user, not all users like this answer suggests.

Any workable solution?

share|improve this question
up vote 1 down vote accepted

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
share|improve this answer
Wow thank you! I'll mark this as correct given that it answers the initial question more accurately. – Christine Cooper Apr 19 '14 at 15:02

It won't be very hard to do. Just add this to your functions.php or into your plugin:

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

This way you will change the default value. So if user changes it, it will remember user's choice.

The only problem is that this setting is common for entire post type editor. I'm afraid it won't be so easy to set it depending on post status (and not breaking anything).

share|improve this answer
Outstanding. And you are absolutely right, the value is the same regardless of post status. – Christine Cooper Apr 18 '14 at 17:56

Your Answer


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.