add_filter('get_terms_orderby', 'order_terms_by_slug', 10, 3);
function order_terms_by_slug($orderby, $args, $taxonomies) {
if($taxonomies[0] == 'artist'){
$orderby = 't.name';
}
return $orderby;
}
ひんとはここから
add_filter('get_terms_orderby', 'your_custom_function', 10, 3);
function your_custom_function($orderby, $args, $taxonomies) {
// your custom code here
return $orderby;
}
$orderby (string): The ORDERBY clause of the terms query. $args (array): An array of term query arguments. $taxonomies (string[]): An array of taxonomy names.
ということで
$taxonomies[0] == としたらうまくいった
$orderby = ‘t.term_id DESC’;
$orderby = ‘t.slug ASC’;
カスタムメタキーで用語を並べ替える
$orderby = “meta_value ASC、t.name ASC”;
ここにも正解かいてあるわ
カスタムメタキーと分類法に基づいて用語を並べ替えます
add_filter('get_terms_orderby', 'order_terms_by_custom_meta_key_and_taxonomy', 10, 3);
function order_terms_by_custom_meta_key_and_taxonomy($orderby, $args, $taxonomies) {
if (in_array('your_taxonomy', $taxonomies)) {
$orderby = "meta_value ASC, t.name ASC";
}
return $orderby;
}