最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Custom Post Type and Custom REST API Endpoint result in Gutenberg editor not working

programmeradmin0浏览0评论

I have a custom post type (article) and have implemented a custom REST API endpoint for that post type. I can retrieve single and multiple articles via the custom endpoint without any issues.

However, when I try to add a new or edit an existing article post within WP Admin, I just get a white screen. The web console shows an error that the rest route does not exist but it is using the standard WP REST Route "No route was found matching the URL and request method." The GET call is to /wp-json/wp/v2/article. The route should be /wp-json/kbs/v1/articles - and that route works. When registering the post type I have the following args...

'show_in_rest'          => true,
'rest_base'             => 'articles',
'rest_controller_class' => 'KBS_Articles_API'

How can I ensure that WP uses the correct route when loading the block editor? Editing with the classic editor works fine.

发布评论

评论列表(0)

  1. 暂无评论