Skip to content

Instantly share code, notes, and snippets.

@jdhobbsuk
Last active October 16, 2015 16:15
Show Gist options
  • Save jdhobbsuk/bccd7f0a92724f553217 to your computer and use it in GitHub Desktop.
Save jdhobbsuk/bccd7f0a92724f553217 to your computer and use it in GitHub Desktop.
Remove pagination from post types (in admin)
// Force CPTs to have no pagination
// -------------------------------------------------------------
if ( is_admin() ) :
function force_no_admin_pagination() {
// get all post types (excluding posts)
$post_types = get_post_types();
unset($post_types['post']);
// get all users
$all_users = get_users( );
$user_list = array();
foreach($all_users as $user):
$user_list[] = $user->id;
endforeach;
foreach($user_list as $user):
foreach($post_types as $post_type):
update_user_option( $user, 'edit_'.$post_type.'_per_page', '9999' );
endforeach;
endforeach;
}
add_action( 'admin_menu', 'force_no_admin_pagination' );
endif;
@jdhobbsuk
Copy link
Author

This snippet of code constantly overrides the 'per page' value found in 'Screen Options' to effectively wipe out pagination within the admin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment