WordPress Development Asked by Dhalucario on October 30, 2021
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
]);
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP