Custom Post Type not showing in Rest API on Multisite

I’m using WP Multisite and can’t seem to pull through my custom post types via the API.

<?php
function terms_post_type() {
$labels = array(
‘name’ => _x( ‘Policies’, ‘Post Type General Name’, ‘name’ ),
‘singular_name’ => _x( ‘Policy’, ‘Post Type Singular Name’, ‘name’ ),
‘menu_name’ => __( ‘Policies’, ‘name’ ),
‘parent_item_colon’ => __( ‘Parent Policy’, ‘name’ ),
‘all_items’ => __( ‘All Policies’, ‘name’ ),
‘view_item’ => __( ‘View Policy’, ‘name’ ),
‘add_new_item’ => __( ‘Add New Policy’, ‘name’ ),
‘add_new’ => __( ‘Add New’, ‘name’ ),
‘edit_item’ => __( ‘Edit Policy’, ‘name’ ),
‘update_item’ => __( ‘Update Policy’, ‘name’ ),
‘search_items’ => __( ‘Search Policy’, ‘name’ ),
‘not_found’ => __( ‘Not Found’, ‘name’ ),
‘not_found_in_trash’ => __( ‘Not found in Trash’, ‘name’ ),
);

$args = array(
‘label’ => __( ‘Policies’, ‘name’ ),
‘description’ => __( ‘Terms and Conditions’, ‘name’ ),
‘labels’ => $labels,
‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘revisions’, ‘custom-fields’, ‘page-attributes’ ),
‘hierarchical’ => true,
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘show_in_nav_menus’ => true,
‘show_in_admin_bar’ => true,
‘menu_position’ => 5,
‘can_export’ => true,
‘has_archive’ => true,
‘exclude_from_search’ => false,
‘publicly_queryable’ => true,
‘capability_type’ => ‘page’,
‘rest_base’ => ‘policy’,
‘show_in_rest’ => true
);

register_post_type( ‘policy’, $args );
}

add_action( ‘init’, ‘terms_post_type’, 1 );

When I then hit http://.localtest.me/wp-json/wp/v2/policy I get:

{
“code”: “rest_no_route”,
“message”: “No route was found matching the URL and request method”,
“data”: {
“status”: 404
}
}

Feel like I’m overlooking something.

Read more here:: Custom Post Type not showing in Rest API on Multisite

Leave a Reply

Your email address will not be published. Required fields are marked *