Skip to content

Instantly share code, notes, and snippets.

@jake-101
Last active July 11, 2019 03:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jake-101/5c930e5af129ecd9f003cac9c7f13273 to your computer and use it in GitHub Desktop.
Save jake-101/5c930e5af129ecd9f003cac9c7f13273 to your computer and use it in GitHub Desktop.
Add ACF field to WPGraphQL WooCommerce
<?php
add_action( 'graphql_register_types', function() {
register_graphql_field( 'Product', 'tech_specs', [
'type' => 'String',
'description' => __( 'tech specs', 'wp-graphql' ),
'resolve' => function( $post ) {
$id = $post->ID;
$specs = get_field( "tech_specs",$id);
$enc = strip_tags($specs,"<p>,<br>,<ul>,<li>");
return $enc;
}
] );
} );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment