admin管理员组文章数量:1130349
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.
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.
本文标签: Custom Post Type not showing in Rest API on Multisite
版权声明:本文标题:Custom Post Type not showing in Rest API on Multisite 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749120411a2318909.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论