WP_Posts_List_Table::get_sortable_columns()protectedWP 1.0

Method of the class: WP_Posts_List_Table{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_sortable_columns();

WP_Posts_List_Table::get_sortable_columns() code WP 6.5.2

protected function get_sortable_columns() {

	$post_type = $this->screen->post_type;

	if ( 'page' === $post_type ) {
		if ( isset( $_GET['orderby'] ) ) {
			$title_orderby_text = __( 'Table ordered by Title.' );
		} else {
			$title_orderby_text = __( 'Table ordered by Hierarchical Menu Order and Title.' );
		}

		$sortables = array(
			'title'    => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ),
			'parent'   => array( 'parent', false ),
			'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
			'date'     => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ),
		);
	} else {
		$sortables = array(
			'title'    => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ),
			'parent'   => array( 'parent', false ),
			'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
			'date'     => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ),
		);
	}
	// Custom Post Types: there's a filter for that, see get_column_info().

	return $sortables;
}