Change Admin Pagination on Posts, Pages and Comments

One or the other users in the backend of WordPress find it quite disturbing that not more than 20 articles, pages and comments per page gets listed. Especially if you work with many tables and you have a fast connection, then an increased number of listed articles, pages, comments is useful. How to adapt and with a little CSS getting the best presentation I will show now, here are some tips.

As of WordPress version 2.8

With WordPress 2.8 comes a new value in the user's options for each page in the backend. This allows each user to extend the number of listed pages, articles and comments per page. If you like to solve it also in advance of WordPress 2.8, then the following syntax helps.

posts_per_page

Alternative Plugin

You should embed the syntax in a Plugin.
I am purposely not providing a Plugin, because the support of my existing solutions is already overwhelming. So it is rather as a basis for people who want to start here and as a memory for me when I need it again.

Some comments I have directly written down in the source code, so it is understandable. Also I do upload a CSS file, the content can be found at the end, which changes the design a little bit and create a better overview of the large number of entries.

posts_per_page2

// value for posts
define( 'FB_CAP_PER_POST', 100 );
// value for pages
define( 'FB_CAP_PER_PAGE', 100 );
// value for comments
define( 'FB_CAP_PER_COMMENT', 100 );

// only in admin area
if ( is_admin() ) {
	global $pagenow;
	
	if ( $pagenow == 'edit-pages.php' ) {
		add_filter( 'manage_pages_query', 'page_ChangeAdminPagination' );
		add_action( 'admin_print_styles', 'AddMyStylesheet' );
	}
	if ( $pagenow == 'edit.php' ) {
		add_action( 'admin_head', 'post_ChangeAdminPagination' );
		add_action( 'admin_print_styles', 'AddMyStylesheet' );
	}
	if ( $pagenow == 'edit-comments.php' )
		add_filter( 'comments_per_page', 'comment_ChangeAdminPagination' );
}
	
function post_ChangeAdminPagination() {
	global $wp_query;
	
	if ( $wp_query->query_vars[s] == '' ) {
		$per_post = (int) FB_CAP_PER_POST;
		$wp_query->query( 'showposts=' . $per_post );
	}
}

function page_ChangeAdminPagination($query) {
	global $per_page;
	
	$per_page = (int) FB_CAP_PER_PAGE;
	//$query['posts_per_page'] = $per_page;
	$query['posts_per_archive_page'] = $per_page;
	
	return $query;
}

function comment_ChangeAdminPagination($count) {

	$per_comment = (int) FB_CAP_PER_COMMENT;
	
	return $per_comment;
}

function AddMyStylesheet() {
	
		$myStyleFile = WP_PLUGIN_URL . '/change_admin_pagination/css/style.css';
		wp_register_style( 'change_admin_pagination', $myStyleFile );
		wp_enqueue_style( 'change_admin_pagination');
}

The following content is intended only to that area for editing the page or next to the entry contribution is shown. Thus, the line is smaller and has more entries available to view.

/**
 * style for smaller tables in admin of WordPress
 * @author Frank Bültge
 * @date 01.04.2009 20:51:59
 */
.post-title strong {
	float: left;
}

.row-actions {
	float: left;
	margin-left: 1% !important;
}

.check-column, tr td {
	padding-bottom: 0 !important;
}


.column-date {
	width: 15% !important;
}

td.date {
	font-size: .6em;
}

td.date abbr {
	float: right;
}

Comments are closed.

7 comments

  1. Christopher Ross

    Very cool Frank!

    In the past I've noticed that the admin tool is a big of a resource pig compared to the front (especially when using a cache script), I'm curious if this hack will help relieve some of the strain it's putting on my server.

  2. Alex Vorn

    Thanks! Maybe I will use these on my future theme 🙂

  3. Frank

    I have updated the function for posts - this is better for filter and pagination. I have seen problems with the first function on WordPress 2.7; I write everything on the nightly build.

    I hope you enjoy:

    function post_ChangeAdminPagination($default_limit) {
    	global $wp_query;
    	
    	// default WP Filter
    	// $limit_filter = create_function( '$a', "return 'LIMIT $start, 10';" )
    	
    	if ( !$default_limit )
    		return $default_limit;
    	
    	// explode values
    	// default: LIMIT 0, 15
    	list( $start, $limit ) = explode(',', $default_limit, 2);
    	
    	$limit = (int) FB_CAP_PER_POST;
    	
    	if ( is_paged() ) {
    		$start = $wp_query->query_vars['offset'];
    		$paged = $wp_query->query_vars['paged'];
    		
    		$start = ($paged - 1) * $limit;
    		
    		$start = 'LIMIT ' . $start;
    	}
    	
    	$wp_query->query_vars['posts_per_page'] = $limit;
    	
    	return $start . ', ' . $limit;
    }
    

    Best regards Frank

  4. link2caro

    For 2.8, filters are better ?

    [source lang=php]
    add_filter( 'edit_posts_per_page', 'cr_posts_per_page' );
    add_filter( 'edit_pages_per_page', 'cr_pages_per_page' );
    [/source]

  5. Frank

    Yes, in 2.8 is this an user-option get_user_option('edit_pages_per_page') and you can set via filter.

2 pingbacks

  1. Tip: Change Pagination in WordPress Admin Panel « WP TOY
  2. Ein ♥ für Blogs - Payamo.de