super-cpt
super-cpt copied to clipboard
Sortable columns option?
Is there a way to make the columns sortable in the admin cpt listing page?
other than using the usual wp coding eg...
function my_sortable_slide_columns( $columns ) {
$columns['slide_order'] = 'slide_order';
return $columns;
}
add_filter( 'manage_edit-slide_sortable_columns', 'my_sortable_slide_columns' );
function my_slide_order( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
if( 'slide_order' == $orderby ) {
$query->set('meta_key','slide_order');
$query->set('orderby','meta_value_num');
}
}
add_action( 'pre_get_posts', 'my_slide_order' );
There isn't a way to do it out of the box, but I'm not opposed to adding it. I'm leaving this open to see if there's a high enough demand for it.