You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Gutenberg, we've experimented with the ability to register fields #67175 for a given entity by means of a client-side function, wp.editor.registerEntityField, which is avaliable when the Gutenberg plugin is active.
We want to go a step further and enable 3rd parties to extend the existing DataViews/DataForm based screens declaratively, from the server. This includes the Site Editor screens for Pages, Templates, and Patterns.
Why
To make it as easy as possible to extend and work with entities (pages, template, patterns).
Expand the system so that fields that require JavaScript can also be declared.
The wordpress/fields packages bundles all fields together but we actually want to have separate bundles per collection (entity) and load them on demand.
Migrate all fields to use the new system
wordpress/fields
wordpress/media-fields
fields declared locally for Site Editor's Patterns
fields declared locally for Site Editor's Templates
Just jotting down a quick comment that for the case of media / attachments, a server-side approach for registering fields for entities should also be able to support (or map) to the filter for attachment_fields_to_edit. I.e. for each field added via that filter, attempt to register an attachment entity field for DataViews/DataForm where possible.
I've written that up in #75123 as it's not an immediate requirement for this issue, but will be for the media editor / registering fields for the attachment entity. So just something for us to keep in mind.
Here is a small plugin to test the fields API from PHP and a script module. It's tested on WordPress trunk with the Gutenberg build.
It adds a Subtitle field to pages, stored in the demo_subtitle post meta:
wp_register_entity_fields() registers the field on wp_entity_fields_api_init.
The script module provides getValue and setValue, which read and write the value through meta.
The get_entity_view_config_posttype_page filter merges the field into the default Pages view and into the form.
To test, add both files to wp-content/plugins/demo-page-field/ and activate the plugin. The field shows in Site Editor > Pages (list and table layouts, after resetting a saved view), in Quick Edit, and in the page editor's document sidebar, and editing it in Quick Edit or the editor saves the meta.
demo-page-field.php:
<?php/** * Plugin Name: Demo Page Field * Description: Adds a "Subtitle" entity field to pages, stored in post meta (Entity Fields API, WordPress 7.2). * Version: 1.0.0 * Requires at least: 7.2 */add_action(
'init',
staticfunction () {
register_post_meta(
'page',
'demo_subtitle',
array(
'type' => 'string',
'single' => true,
'default' => '',
'show_in_rest' => true,
'sanitize_callback' => 'sanitize_text_field',
)
);
wp_register_script_module( 'demo-page-field', plugins_url( 'fields.js', __FILE__ ), array(), '1.0.0' );
}
);
add_action(
'wp_entity_fields_api_init',
staticfunction () {
wp_register_entity_fields(
'demo-page-field',
'postType',
'page',
array(
array(
'id' => 'demo_subtitle',
'type' => 'text',
'label' => __( 'Subtitle', 'demo-page-field' ),
'description' => __( 'A short line shown under the page title.', 'demo-page-field' ),
'enableSorting' => false,
'filterBy' => false,
),
),
'demo-page-field'
);
}
);
// Show the field in the Pages list and in the page editor's inspector.add_filter(
'get_entity_view_config_posttype_page',
staticfunction ( $data ) {
return$data->merge(
array(
'default_view' => array( 'fields' => array( 'demo_subtitle' ) ),
'form' => array( 'fields' => array( 'demo_subtitle' ) ),
),
1
);
}
);
fields.js:
// The JavaScript parts of the fields registered in demo-page-field.php, keyed by field id.// The value lives in post meta, so it is read from and written to `meta`.exportdefault{demo_subtitle: {getValue: ({ item })=>item.meta?.demo_subtitle??'',setValue: ({ value })=>({meta: {demo_subtitle: value}}),},};
Activity
andrewserong commentedon Feb 2, 2026
Just jotting down a quick comment that for the case of media / attachments, a server-side approach for registering fields for entities should also be able to support (or map) to the filter for
attachment_fields_to_edit. I.e. for each field added via that filter, attempt to register an attachment entity field for DataViews/DataForm where possible.I've written that up in #75123 as it's not an immediate requirement for this issue, but will be for the media editor / registering fields for the attachment entity. So just something for us to keep in mind.
oandregal commentedon Feb 17, 2026
Removed from the 7.0 project as this is not making it to WordPress 7.0 — we've focused on other features instead.
oandregal commentedon Mar 9, 2026
I've started to work on this: added some initial tasks in the issue description, and prepared #76332 to bootstrap the server-side registration API.
jorgefilipecosta commentedon Oct 20, 2026
Here is a small plugin to test the fields API from PHP and a script module. It's tested on WordPress trunk with the Gutenberg build.
It adds a Subtitle field to pages, stored in the
demo_subtitlepost meta:wp_register_entity_fields()registers the field onwp_entity_fields_api_init.getValueandsetValue, which read and write the value throughmeta.get_entity_view_config_posttype_pagefilter merges the field into the default Pages view and into the form.To test, add both files to
wp-content/plugins/demo-page-field/and activate the plugin. The field shows in Site Editor > Pages (list and table layouts, after resetting a saved view), in Quick Edit, and in the page editor's document sidebar, and editing it in Quick Edit or the editor saves the meta.demo-page-field.php:fields.js: