You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为什么WordPress 6.1默认文章编辑器与自定义文章类型UI不一致?

解决自定义文章类型(News)编辑器布局与默认文章不一致的问题

核心问题出在你注册自定义文章类型的代码里——show_in_rest参数被设为false,这导致你的News类型用的是旧版经典编辑器,而默认文章类型启用了古腾堡(Block Editor)的现代化布局。

修改步骤:

  1. 打开主题的functions.php,找到注册News的代码块
  2. 在$args数组里,把'show_in_rest' => false,改成'show_in_rest' => true,

修改后的完整$args部分代码:

$args   = [
    'label'               => __('News', 'text_domain'),
    'description'         => __('News', 'text_domain'),
    'labels'              => $labels,
    'supports'            => [
        'title', 'editor', 'comments', 'custom-fields', 'author', 'thumbnail', 'post-formats', 'page-attribute',
        'excerpt'
    ],
    'taxonomies'          => ['category', 'post_tag'],
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'menu_position'       => 5,
    'menu_icon'           => 'dashicons-list-view',
    'show_in_admin_bar'   => true,
    'show_in_nav_menus'   => true,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'post',
    'show_in_rest'        => true, // 这里改成true
];

额外说明:

  • show_in_rest参数控制自定义文章类型是否支持WordPress的REST API,而古腾堡编辑器依赖REST API才能正常运行,开启后就会自动切换到和默认文章一致的现代化布局。
  • 修改代码后,刷新后台页面,如果编辑器没切换,建议清除浏览器缓存再试。
  • 如果你安装了「经典编辑器」插件,要确保没有强制给News类型启用经典编辑器(可以在插件设置里检查)。

内容的提问来源于stack exchange,提问作者danny

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 05:21:55