Admin & Dashboard PHP Beginner

Change the Posts Per Page Count in Admin List Tables

Override the number of posts shown per page in WordPress admin list tables on a per-post-type basis, without requiring each user to change their Screen Options.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 10 lines
add_filter( 'edit_posts_per_page', function( $per_page, $post_type ) {
    $overrides = [
        'post'           => 25,
        'page'           => 50,
        'nahnu_snippet'  => 50,
        'product'        => 30,
    ];

    return $overrides[ $post_type ] ?? $per_page;
}, 10, 2 );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

WordPress shows 20 items per page in admin list tables by default, the Posts screen, Pages screen, Media Library, and any custom post type list table all default to 20. Every user can override this individually through Screen Options, but that setting is stored per-user and resets when a user logs in on a different device or browser. For site administrators and developers managing sites with large content libraries, the default of 20 means excessive pagination when reviewing content.

This snippet sets sensible defaults on a per-post-type basis so every user gets a more practical starting point without needing to configure Screen Options manually.

What the code does

The edit_posts_per_page filter receives the current count and the post type slug, making it straightforward to apply different values per post type.

Choosing the Right Values

The right per-page count depends on how content is managed. For post types where editors scan a long list looking for specific posts, blog posts, products, higher values like 30 or 50 reduce the number of times an editor has to paginate. For post types with very long titles or many visible columns, a smaller count keeps the table readable without horizontal scrolling.

Pages are typically fewer in number and more individually important, so 50 per page is appropriate for most sites, you want to see all pages at once without pagination on small to medium sites. Custom post types with dozens of entries but few columns are candidates for larger values.

User Overrides Still Work

This filter sets the default per-page value but doesn’t lock it. Users can still open Screen Options and set their preferred count, which is stored in their user meta and takes precedence over the filter for that user on that device. The filter only affects users who haven’t set a personal preference, which is most users, most of the time.

The ?? Operator

The ?? $per_page at the end of the return uses the null coalescing operator to fall back to WordPress’s default for any post type not in the $overrides array. This ensures the filter has no effect on post types you haven’t explicitly configured, media, revisions, attachments, and any other registered post types continue using the WordPress default.

Media Library

The Media Library uses a different per-page option and is not affected by edit_posts_per_page. To change the Media Library grid’s items-per-page, look for the upload_per_page filter. The list view of the Media Library follows the attachment post type and can be controlled with this filter using 'attachment' as the post type key.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only