Using the following snippet will let you add sortable column in WordPress admin area.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | add_filter( 'manage_posts_columns', 'namespace_AddXXXColumn' ); add_action( 'manage_posts_custom_column', 'namespace_AddXXXValue', 10, 2 ); function namespace_AddXXXColumn($cols) { $cols['xxx'] = __('XXX'); return $cols; } function namespace_AddXXXValue($column_name, $post_id) { if ( 'xxx' == $column_name ) { echo get_permalink($post_id); // for example } } // Register the column as sortable function xxx_column_register_sortable( $columns ) { $columns['xxx'] = 'xxx'; return $columns; } add_filter( 'manage_edit-post_sortable_columns', 'xxx_column_register_sortable' ); |
Snippet Source/Credit: Snipplr