1
我想根據價格,日期和發佈年份等項目對產品進行分類。 在發佈年份的情況下,我做了分類=發佈年份& post_type = product併爲其設置年份。 現在我想按年排序。我的代碼是這樣的:woocommerce產品如何通過產品標籤獲得訂單
case 'rand' : $curr_args['orderby'] = 'rand'; break; case 'date' : $curr_args['orderby'] = 'date'; $curr_args['order'] = $order == 'ASC' ? 'ASC' : 'DESC'; break; case 'price' : global $wpdb; $curr_args['orderby'] = "meta_value_num {$wpdb->posts}.ID"; $curr_args['order'] = $order == 'DESC' ? 'DESC' : 'ASC'; $curr_args['meta_key'] = '_price'; break; case 'popularity' : $curr_args['meta_key'] = 'total_sales'; add_filter('posts_clauses', array(WC()->query, 'order_by_popularity_post_clauses')); break; case 'release-year' : $curr_args['orderby'] = 'release-year'; $curr_args['order'] = $order == 'ASC' ? 'ASC' : 'DESC'; $curr_args['tax_query'] = array(array('taxonomy' => 'release-year',);); case 'title' : $curr_args['orderby'] = 'title'; $curr_args['order'] = $order == 'DESC' ? 'DESC' : 'ASC'; break;
但它不工作。我如何將代碼更改爲按發佈年份順序進行排序?