Skip to content

Instantly share code, notes, and snippets.

@jasonbahl
Created May 2, 2022 16:03
Show Gist options
  • Save jasonbahl/7056c8fd83622004d060bf1819291dd2 to your computer and use it in GitHub Desktop.
Save jasonbahl/7056c8fd83622004d060bf1819291dd2 to your computer and use it in GitHub Desktop.
show wp-template-part and wp-template-part-area in GraphQL
add_filter( 'register_post_type_args', function( $args, $post_type ) {
if ( 'wp_template_part' === $post_type ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'TemplatePart';
$args['graphql_plural_name'] = 'TemplateParts';
}
return $args;
}, 10, 2 );
add_filter( 'register_taxonomy_args', function( $args, $taxonomy ) {
if ( 'wp_template_part_area' === $taxonomy ) {
$args['show_in_graphql'] = true;
$args['graphql_single_name'] = 'TemplatePartArea';
$args['graphql_plural_name'] = 'TemplatePartAreas';
}
return $args;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment