custom post types - WordPress Rest API only returns content when posttype has editor capability

I am trying to request my post via the WordPress V2 Rest API in the backend. For whatever reason the post content is onl

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信