Answers for "Add WordPress custom post type to rest api"

0

Add WordPress custom post type to rest api

/**
 * Register a book post type, with REST API support
 *
 * Based on example at: https://codex.wordpress.org/Function_Reference/register_post_type
 */
add_action( 'init', 'my_book_cpt' );
function my_book_cpt() {
    $args = array(
      'public'       => true,
      'show_in_rest' => true,
      'label'        => 'Books'
    );
    register_post_type( 'book', $args );
}
Posted by: Guest on June-04-2021

Code answers related to "Add WordPress custom post type to rest api"

Browse Popular Code Answers by Language