feat: Initial WordPress project
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
// Expose 'bg_pos_desktop' post meta on MediaItem type in WPGraphQL
|
||||
add_action( 'graphql_register_types', 'leblanc_graphql_register_media_focus_point' );
|
||||
function leblanc_graphql_register_media_focus_point() {
|
||||
register_graphql_field(
|
||||
'MediaItem',
|
||||
'objectPosition',
|
||||
array(
|
||||
'type' => 'String',
|
||||
'description' => 'CSS object-position value from Media Focus Point plugin',
|
||||
'resolve' => static function ( $media_item ) {
|
||||
return get_post_meta( $media_item->databaseId, 'bg_pos_desktop', true );
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
// Override term connection query args
|
||||
add_filter( 'graphql_term_object_connection_query_args', 'headless_graphql_term_object_connection_query_args', 10, 3 );
|
||||
function headless_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