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.
The Code
Add this to your functions.php or a site-specific plugin. 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.
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 );
