Created
          May 2, 2022 16:03 
        
      - 
      
- 
        Save jasonbahl/7056c8fd83622004d060bf1819291dd2 to your computer and use it in GitHub Desktop. 
    show wp-template-part and wp-template-part-area in GraphQL
  
        
  
    
      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_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