manage_{$this->screen->id}_sortable_columns

最后更新于:2021-11-27 06:45:36

apply_filters( “manage_{$this->screen->id}_sortable_columns”, array $sortable_columns )

Filters the list table sortable columns for a specific screen.

参数

$sortable_columns

(array)
An array of sortable columns.

源文件

文件: gc-admin/includes/class-gc-list-table.php

View on Trac

// the basic support
add_post_type_support( $my_post_type, 'page-attributes' );

// add a column to the post type's admin
add_filter( 'manage_' . $my_post_type . '_posts_columns', function( $columns ) {
  $columns['menu_order'] = __( 'Order', 'textdomain' ); 
  return $columns;
} );

// display the column value
add_action( 'manage_' . $my_post_type . '_posts_custom_column', function( $column_name, $post_id ) {
  if ( 'menu_order' === $column_name ) {
    echo __( get_post( $post_id )->menu_order, 'textdomain' );
  }
}, 10, 2 ); // priority, number of args - MANDATORY HERE! 

// ... and make it sortable with the code from the start