admin管理员组文章数量:1331849
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
]);
本文标签: custom post typesWordPress Rest API only returns content when posttype has editor capability
版权声明:本文标题:custom post types - WordPress Rest API only returns content when posttype has editor capability 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742258460a2442065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论