add_action( 'graphql_register_types', function() {
register_graphql_field( 'RootQuery', 'siteLogo', [
'type' => 'MediaItem',
'description' => __( 'The logo set in the customizer', 'your-textdomain' ),
'resolve' => function() {
$logo_id = get_theme_mod( 'custom_logo' );
if ( ! isset( $logo_id ) || ! absint( $logo_id ) ) {
return null;
}
$media_object = get_post( $logo_id );
return new \WPGraphQL\Model\Post( $media_object );
}
] );
} );
0 Comments
Post a Comment