Skip to content

Instantly share code, notes, and snippets.

@websupporter
Created August 29, 2016 06:10
Show Gist options
  • Save websupporter/e15c829d8444dccc069e33f97c36eccf to your computer and use it in GitHub Desktop.
Save websupporter/e15c829d8444dccc069e33f97c36eccf to your computer and use it in GitHub Desktop.
How to register a custom post type for the REST API #wcfra
<?php
function register_cpt() {
$args = array(
'labels' => array(
'name' => 'Name',
'singular_name' => 'Single',
),
'menu_position' => 5,
'public' => true,
'show_in_rest' => true, // Mache diesen Post Type über die API zugänglich.
);
register_post_type( 'cpt', $args );
}
add_action( 'init', 'register_cpt' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment