当前位置:首页>网络教程>让自定义文章类型支持古腾堡编辑器的WordPress教程

让自定义文章类型支持古腾堡编辑器的WordPress教程

WordPress启用Gutenberg编辑器作为默认文章编辑器后会发现创建的自定义文章类型在添加文章的时候使用的还是TinyMCE编辑器, ...

WordPress启用Gutenberg编辑器作为默认文章编辑器后会发现创建的自定义文章类型在添加文章的时候使用的还是TinyMCE编辑器,要让自定义文章类型支持古腾堡编辑器,还需要在register_post_type中添加show_in_rest参数,据了解是大致是因为Gutenberg编辑器必须利用REST API进行更新和更改,总之问题是解决了。今天分享一下让自定义文章类型支持古腾堡编辑器的WordPress教程。

让自定义文章类型支持古腾堡编辑器的WordPress教程

代码如下:

$args = array(

‘labels’ => $labels,

‘description’ => ‘产品列表’,

‘public’ => true,

‘menu_position’ => 5,

‘supports’ => array(‘title’,’editor’,’thumbnail’), //supports中需要有editor

‘show_in_rest’ => true,//增加的参数

‘has_archive’ => true

);

register_post_type( ‘product_type’, $args );

WordPress官网对参数的说明

‘show_in_rest’

(bool) Whether to include the post type in the REST API. Set this to true for the post type to be available in the block editor.

给TA打赏
共{{data.count}}人
人已打赏
网络教程

WordPress如何禁用缩略图自动裁剪功能从而节约网站空间?

2022-7-15 18:11:31

网络教程

取消文章评论回复WordPress函数cancel_comment_reply_link()

2022-7-15 18:11:55

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索