Skip to content

Instantly share code, notes, and snippets.

@MjHead
Last active November 9, 2021 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MjHead/43d1f8a09a88548dc813539b7f7a8619 to your computer and use it in GitHub Desktop.
Save MjHead/43d1f8a09a88548dc813539b7f7a8619 to your computer and use it in GitHub Desktop.
Register meta field to show in Rest API
add_action( 'init', function() {
// replace your-post-type-slug and your-meta-field-name with your actual data
register_post_meta( 'your-post-type-slug', 'your-meta-field-name', array(
'single' => true,
'type' => 'string',
'default' => '',
'auth_callback' => '__return_true',
'show_in_rest' => true,
) );
}, 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment