Custom pagination for wordpress admin dashboard table


/* Custom pagination for wordpress admin dashboard table start */

$per_page = 3;
if (isset($_GET[‘paged’])) { $page = $_GET[‘paged’]; } else { $page=1; };
$start_page = ($page-1) * $per_page;
$this->items = $wpdb->get_results(“SELECT * FROM $table_name LIMIT $start_page, $per_page”, ARRAY_A);

// [REQUIRED] configure pagination
$this->set_pagination_args(array(
‘total_items’ => $total_items, // total items defined above
‘per_page’ => $per_page, // per page constant defined at top of method
‘total_pages’ => ceil($total_items / $per_page) // calculate pages count
));

/* Custom pagination for wordpress admin dashboard table end */

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s