Shop_coupon: make the expiry date column sortable
-
I’m trying to make the expiry_date column sortable.
I guess the problem has something to do with an incorrect meta key value.
function my_sortable_expiry_date_column( $columns ) { $columns['expiry_date'] = 'expiry_date'; //To make a column 'un-sortable' remove it from the array //unset($columns['date']); return $columns; } add_filter( 'manage_edit-shop_coupon_sortable_columns', 'my_sortable_expiry_date_column' );
function my_expiry_date_orderby( $query ) { if( ! is_admin() ) return; $orderby = $query->get( 'orderby'); if($orderby == 'expiry_date') { $query->set('meta_key','expiry_date'); $query->set('orderby','meta_value_num'); } } add_action( 'pre_get_posts', 'my_expiry_date_orderby' );
How can I find the correct meta_key? How do I orberby ‘date types’ column?
Thnx!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Shop_coupon: make the expiry date column sortable’ is closed to new replies.