I am trying to request my post via the WordPress V2 Rest API in the backend. For whatever reason the post content is only returned when my custom post type has the editor
support enabled. Is there a way to get the post content in the same request without having to enable the Gutenberg Editor?
My fetch request:
apiFetch({
path: addQueryArgs('/wp/v2/my_custom_post_type/' + postId, {
context: 'edit'
})
}).then((post) => {
console.log(post);
});
My post type:
register_post_type('my_custom_post_type', [
'labels' => [
'name' => 'My Custom Post Types',
'singular_name' => 'My Custom Post Type'
],
'public' => false,
'show_in_rest' => true,
'hierarchical'=> false,
'show_ui' => true,
'menu_icon' => 'dashicons-grid-view',
'supports' => [
'revisions',
],
'has_archive' => false
]);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742258461a4410458.html
评论列表(0条)