function prepare_items() { // number of items per page $per_page = 10; // define column headers $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); // retrieve data // TODO select data for current page only $data = \Podlove\Model\Show::all(); // get current page $current_page = $this->get_pagenum(); // get total items $total_items = count($data); // extrage page for current page only $data = array_slice($data, ($current_page - 1) * $per_page, $per_page); // add items to table $this->items = $data; // register pagination options & calculations $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page))); }