WP_List_Table::get_sortable_columns(): array<string,

Gets a list of sortable columns.

Description

The format is:

  • 'internal-name' => 'orderby'
  • 'internal-name' => array( 'orderby', bool, 'abbr', 'orderby-text', 'initially-sorted-column-order' )
  • 'internal-name' => array( 'orderby', 'asc' ) – The second element sets the initial sorting order.
  • 'internal-name' => array( 'orderby', true ) – The second element makes the initial order descending.

In the second format, passing true as second parameter will make the initial sorting order be descending. Following parameters add a short column name to be used as ‘abbr’ attribute, a translatable string for the current sorting, and the initial order for the initial sorted column, ‘asc’ or ‘desc’ (default: false).

Return

array<string, array<int, string|bool>|string> An associative array of sortable columns.

More Information

This method should be overridden to return an associative array of columns that you want to make sortable. The associative array should follow the format 'column_slug'=>array('sortby',true), where the second property states whether the field is presorted. This is frequently used to provide part of the _column_headers property.

Source

protected function get_sortable_columns() {
	return array();
}

Changelog

VersionDescription
6.3.0Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'.
3.1.0Introduced.

User Contributed Notes

  1. Skip to note 2 content
       /**
         * Get sortable columns
         * @return array
         */
        function get_sortable_columns(){
            $s_columns = array (
                'title' => [ 'title', true], 
                'deposit' => [ 'deposit', true],
            );
            return $s_columns;
        }

You must log in before being able to contribute a note or feedback.