I have created a custom post type called ‘customers’. I’m registering step by step as the documentation says. But when I make a call to the rest api, it just returns a 404 response. See the code below:
add_action('init', 'customer_post_type');
function customer_post_type() {
$labels = array(
'name' => _x('Customers', 'customers'),
'singular_name' => _x('Customer', 'customers'),
'menu_name' => __('Customers', 'customers'),
'parent_item_colon' => __('Parent Customer', 'customers'),
'all_items' => __('All Customers', 'customers'),
'view_item' => __('View Customer', 'customers'),
'add_new_item' => __('Add New Customer', 'customers'),
'add_new' => __('Add New', 'customers'),
'edit_item' => __('Edit Customer', 'customers'),
'update_item' => __('Update Customer', 'customers'),
'search_items' => __('Search Customer', 'customers'),
'not_found' => __('Not Found', 'customers'),
'not_found_in_trash' => __('Not found in Trash', 'customers'),
);
$args = array(
'label' => __('Customers', 'customers'),
'description' => __('Customer news and reviews', 'customers'),
'labels' => $labels,
'supports' => array('title', 'author', 'thumbnail', 'custom-fields', ),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'menu_icon' => 'dashicons-desktop',
'show_in_rest' => true,
'rest_base' => 'customer',
'rest_controller_class' => 'WP_REST_Post_Controller'
);
register_post_type('customer', $args);
}
the urls that I am testing for, are: /wp-json/wp/v2/customers
and /wp-json/wp/v2/customer