fix: term_order and default WPGraphQL settings
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?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;
|
||||
}
|
||||
Reference in New Issue
Block a user