其他一切都很好,但仍然不能按数字排序。
我只是想知道我做错了什么
这是密码
function add_user_columns( $defaults ) {
$defaults[\'user_votecount\'] = __(\'Votes\', \'user-column\');
return $defaults;
}
function add_custom_user_columns($value, $column_name, $id) {
if( $column_name == \'user_votecount\' ) {
return get_the_author_meta( \'wp__user_like_count\', $id ); }
add_action(\'manage_users_custom_column\', \'add_custom_user_columns\', 15, 3);
add_filter(\'manage_users_columns\', \'add_user_columns\', 15, 1);
function user_sortable_columns( $columns ) {
$columns[\'user_votecount\'] = \'Votes\';
return $columns;
}
add_filter( \'manage_users_sortable_columns\', \'user_sortable_columns\' );
function user_column_orderby( $vars ) {
if ( isset( $vars[\'orderby\'] ) && \'user_votecount\' == $vars[\'orderby\'] ) {
$vars = array_merge( $vars, array(
\'meta_key\' => \'wp__user_like_count\',
\'orderby\' => \'meta_value_num\',
\'order\' => \'asc\'
) );
}
return $vars;
}
add_filter( \'request\', \'user_column_orderby\' );