我正在使用WP_List_Table创建自定义插件。我正在使用从其他来源复制的代码,一切工作正常,除了根据 ID 列或订单号列(在 My SQL 数据库中定义的“int”)对表进行排序时除外。
这是继承WP_List_Table类的类代码:
<?php
if(!class_exists('WP_List_Table')){
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class TT_Example_List_Table extends WP_List_Table {
function __construct(){
global $status, $page;
//Set parent defaults
parent::__construct( array(
'singular' => 'movie', //singular name of the listed records
'plural' => 'movies', //plural name of the listed records
'ajax' => false //does this table support ajax?
) );
}
function column_default($item, $column_name){
switch($column_name){
case 'id':
case 'name_english':
case 'name_arabic':
case 'ordering_number':
return $item[$column_name];
default:
return print_r($item,true); //Show the …Run Code Online (Sandbox Code Playgroud)