Last active
March 8, 2022 08:39
-
-
Save jkhaui/b91517dda66dc84ec3deaaa4edd9a63f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
] ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// Add Votes to Custom Meta Fields add_action( 'graphql_register_types', function() { register_graphql_field( 'case_study_type', 'section_tree', [ 'type' => 'String', 'description' => __( 'Casestudy Section Tree', 'wp-graphql' ), 'resolve' => function( \WP_Term $term ) { $sectiononecontent = get_term_meta($term->term_id , 'section_tree', true); return ! empty( $sectiononecontent ) ? $sectiononecontent : 0; } ] ); } );
Post Type : case_study
Taxonomy Type : case_study_type
code is not working can you please help me