I've added a new page to my admin area, and am now trying to add an admin table to this page, using the WP List Table class (per these instructions). Per the instructions, I would like to first display just an empty table: simply headers, with no rows of data (as in this screenshot). I'm having trouble doing so. I've added the suggested code, but my table still displays only
No items found.
, with no headers (screenshot). Any ideas why this is occurring? My code is below.
There are no errors in the PHP log.
I've also seen these instructions, which are similar (but not identical to) the instructions I'm using. But following them yields the same issue.
Thanks in advance.
Code added to functions.php
if(!class_exists('WP_List_Table')){
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class User_List_Table extends WP_List_Table {
public function get_columns() {
$table_columns = array(
'cb' => '<input type="checkbox" />', // to display the checkbox.
'user_login' => 'User Login',
'display_name' => 'Display Name',
'ID' => 'User Id'
);
return $table_columns;
}
public function prepare_items() {}
}
Code added to page to display the table.
$wp_list_table = new User_List_Table();
$wp_list_table->display();