add_action( 'graphql_register_types', function() {
register_graphql_field( 'Hashtag', 'hashtagImg', [
'type' => 'String',
'description' => __( 'The image (URL) for a topic.', 'wp-graphql' ),
'resolve' => function( \WP_Term $term ) {
$topic_meta = get_term_meta( $term->id, '_topic_image', true );
$img_post = wp_get_attachment_url( $topic_meta );
return ! empty( $img_post ) ? $img_post : null;
}
] );
} );