14 lines
500 B
PHP
14 lines
500 B
PHP
<?php
|
|
|
|
// Override TermConnection query args
|
|
add_filter( 'graphql_term_object_connection_query_args', 'moonshine_graphql_term_object_connection_query_args', 10, 3 );
|
|
function moonshine_graphql_term_object_connection_query_args( $query_args, $source, $args ) {
|
|
// Sort by 'order' meta value instead of legacy 'term_order' field
|
|
if ( 'term_order' === $args['where']['orderby'] ?? false ) {
|
|
$query_args['meta_key'] = 'order';
|
|
$query_args['orderby'] = 'meta_value_num';
|
|
}
|
|
|
|
return $query_args;
|
|
}
|