You need to enable JavaScript to run this app. WordPress自定义Meta字段未在自定义文章类型Post Editor中显示
优惠活动
大模型
产品
解决方案
定价
更多

WordPress自定义Meta字段未在自定义文章类型Post Editor中显示

WordPress自定义Meta字段编辑器显示异常问题反馈

开发阶段说明

  • 目前在WordPress自定义文章类型、自定义Meta字段开发方向经验尚浅,正在系统学习WordPress REST API相关开发内容
  • 现阶段编写了一款测试插件,核心功能为注册自定义Meta字段,插件完整代码如下:
/**
 * @package api_testing
 * @version 1.0.0
 */
/*
Plugin Name: API Testing
Plugin URI: http://example.com/
Description: The beginning of an awesome plugin
Author: Me
Version: 1.0.0
Author URI: http://example.com/
*/

function generate_press_type() {
    $labels = array(
        'name'                  => 'Press Articles',
        'singular_name'         => 'Press',
    );
    $args = array(
        'label'                 => 'Press',
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'custom-fields', 'thumbnail' ),
        'taxonomies'            => array( 'category', 'post_tag' ),
        'hierarchical'          => false,
        'public'                => true,
        'capability_type'       => 'post',
        'show_in_rest'          => true,
        'rest_base'             => 'press-articles',
        'rewrite'               => true,
        'rewrite_slug'          => '',        
    );
    register_post_type( 'press_article', $args );

    $meta_args = array(
        'type'         => 'string',
        'description'  => 'source',
        'single'       => true,
        'show_in_rest' => true,
    );

    register_post_meta( 'press_article', 'source', $meta_args );
    
}
add_action( 'init', 'generate_press_type', 0 );

已确认正常的功能点

  • 插件激活后,WordPress后台可以正常看到注册的press文章类型,支持正常创建、编辑对应文章内容
  • 调用REST接口查询对应文章内容时,注册的自定义Meta字段source可以正常出现在接口返回的响应载荷中

存在的问题与排查进展

  • 预期目标:让source字段可以直接展示在文章编辑器的编辑界面中
  • 异常表现:打开文章编辑器的自定义字段下拉列表,找不到已经注册的source字段,对应异常操作界面已留存截图
  • 排查情况:已对照WordPress官方文档核对所有注册参数,自认为已经覆盖所有要求的必要参数,但问题仍未解决,需要确认是否在注册文章类型或Meta字段时遗漏了关键配置项。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.11.18 16:15:06