I am using WP_List_Table class to create tables in Admin panel. I am trying to implement Sorting feature.

enter image description here

I am using below code

public function prepare_items() {
   $this->items = $this->example_data;
   $columns = $this->get_columns();
   $hidden = $this->get_hidden_columns();
   $sortable = $this->get_sortable_columns();
   $this->_column_headers = array($columns,$hidden,$sortable);

public function get_sortable_columns() {
   return array(
    'booktitle'=> array('Title',true)

public function get_columns() {
   $columns = array(
     'booktitle' => 'Title',
     'author' => 'Author',
     'isbn' => 'ISBN'
   return $columns;

But I am getting below error.

enter image description here

  • 1
    Does your class have the get_hidden_columns method? Because WP_List_Table doesn't have it, so you need to create it and be sure to return a proper array. – Sally CJ May 6 '19 at 7:32
  • Thanks @SallyCJ, get_hidden_columns needed for Sorting ? – abu abu May 6 '19 at 7:40
  • 1
    No, but the error shown on the image seems to originate from here: $hidden = $this->get_hidden_columns();. So to get rid of the error, create the method or use the get_hidden_columns function and not $this->get_hidden_columns(). – Sally CJ May 6 '19 at 7:46
  • 1
    The sortable columns are those returned by this method: get_sortable_columns of your class. And you'd sort the items using the prepare_items method. – Sally CJ May 6 '19 at 7:50
  • 1
    Thanks @SallyCJ. You are correct. Thanks. – abu abu May 6 '19 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.