Skip to content

[DevHub] Docs: Add detailed entity configuration reference to data-core documentation #2161

Open

Description

@Anuj-Rathore24

Issue Description

The current data-core documentation explains how to use selectors like getEntityRecords and getEntityRecord, but it does not document how entities themselves are defined and configured.

Section of Page with the issue

Every selectors for Entities, starting from geteditedentityrecord

Why is this a problem?

At the moment, developers need to read the source code to discover the meaning of these fields.

Suggested Fix

Add a dedicated section to the data-core documentation that explains:

  • The entity configuration object structure.
  • The purpose of each field with examples.

Activity

  1. Anuj-Rathore24 commented on Jan 21, 2026

    @Anuj-Rathore24
    Author

    /assign

  2. github-actions commented on Jan 21, 2026

    @github-actions

    Heads up @WordPress/docs-issues-coordinators, we have a new issue open. Time to use 'em labels.

  3. github-actions commented on Jan 21, 2026

    @github-actions

    Hey @Anuj-Rathore24, thanks for your interest in this issue! 🍪🍪🍪
    If you have any questions, do not hesitate to ask them in our #docs Slack channel.
    Enjoy and happy contributing ❤️

  4. Anuj-Rathore24 commented on Jan 21, 2026

    @Anuj-Rathore24
    Author

    WordPress Data Store – Entity Configuration & Usage

    Entity configs define how WordPress talks to REST API endpoints, normalizes responses, and stores them in the centralized state tree.

    Basic Shape of an Entity

    Every entity follows this general structure:

    {
      label,
      name,
      kind,
      key,
      baseURL,
      baseURLParams,
      plural,
      // optional extras:
      supportsPagination,
      rawAttributes,
      transientEdits,
      getTitle,
      getRevisionsUrl
    }
    
    

    Not all entities use all properties, but they all follow this pattern.

    Properties

    Label

    Meaning - Human-readable name for the entity.

    label: __("Post Type")
    label: __("User")
    label: __("Media")
    

    This value does not affect logic. It is purely descriptive.

    name

    Meaning - The internal identifier of the entity.

    This is the value used in selectors like getEntityRecords.

    All types of names:

    name: "postType"
    name: "user"
    name: "media"
    name: "taxonomy"
    name: "sidebar"
    name: "widget"
    name: "widgetType"
    name: "comment"
    name: "menu"
    name: "menuItem"
    name: "menuLocation"
    name: "globalStyles"
    name: "theme"
    name: "plugin"
    name: "status"
    name: "attachment" // Deprecated Entities
    

    Example:

    select( coreDataStore ).getEntityRecords(
      'root',
      'user'
    );
    

    kind

    Meaning - Namespace for grouping entities.

    In core
    Almost all core entities use:

    kind: "root" // Almost all core entities use
    

    key

    Meaning - The field that uniquely identifies a single record.

    Example:

    Entity Key
    postType "slug"
    taxonomy "slug"
    menuLocation "name"
    theme "stylesheet"
    plugin "plugin"
    status "slug"
    getEntityRecord( 'root', 'taxonomy', 'sports' );
    
    

    baseURL

    Meaning - The REST API endpoint for the entity.

    Example:

    "/wp/v2/users"
    "/wp/v2/media"
    "/wp/v2/taxonomies"
    "/wp/v2/plugins"
    

    baseURLParams

    Meaning - Default query parameters appended to every request.

    Value Meaning
    "view" Public data only
    "edit" Includes private/admin fields
    "embed" Minimal representation

    Example:

    baseURLParams: { context: "edit" }
    GET /wp/v2/users?context=edit // REST call generated
    

    plural

    Meaning - Plural form used internally for state storage.

    plural: "users"
    plural: "mediaItems"
    plural: "postTypes"
    plural: "taxonomies"
    

    Optional Advanced Properties

    supportsPagination

    Meaning - Indicates whether the REST endpoint supports pagination.

    Used by

    • Infinite scroll
    • Paginated lists
    • Query UIs

    Entities that support it

    • users
    • media
    • comments
    • menus
    • menuItems
    • globalStyles

    rawAttributes

    Meaning - Fields that should not be deeply normalized or transformed.

    Example:

    rawAttributes: ["caption", "title", "description"]
    

    transientEdits

    Meaning - Marks fields that support temporary local edits before saving.

    Used for

    • Widgets
    • Sidebars

    This allows editing blocks in memory before persisting.

    getTitle

    Meaning - Custom function to derive a display title from a record.

    Example:

    getTitle: (record) => record?.name || record?.slug
    

    getRevisionsUrl

    Meaning - Custom function to build the revisions endpoint.

    Example:

    getRevisionsUrl: (parentId, revisionId) =>
      `/wp/v2/global-styles/${parentId}/revisions/${revisionId}`
    

    _unstableBase

    meaning - A special internal entity that represents global site-level information.

    What it returns?

    Field Meaning Comes from
    name Site title Settings → General
    description Tagline Settings → General
    home Home URL Site URL
    url Site URL (same here) WordPress URL
    gmt_offset Time offset Timezone settings
    timezone_string Timezone Timezone settings
    page_on_front Front page ID Reading settings
    page_for_posts Blog page ID Reading settings
    show_on_front posts / page Reading settings
    site_icon Site icon attachment ID Customizer
    site_icon_url Icon URL Derived
    site_logo Logo attachment ID Theme
  5. Anuj-Rathore24 commented on Jan 22, 2026

    @Anuj-Rathore24
    Author

    Real-World Examples of Using Entities

    1. Fetching All Users for an Author Selector

    const users = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecords(
        'root',
        'user',
        { per_page: 100 }
      )
    );
    
    

    What happens internally?

    GET /wp/v2/users?context=edit&per_page=100
    

    2. Getting a Single Post Type Configuration

    const postType = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecord(
        'root',
        'postType',
        'post'
      )
    );
    const supportsExcerpt = postType?.supports?.excerpt;
    

    What happens internally?

    GET /wp/v2/types/post?context=edit
    

    3. Building a Media Library Grid

    const mediaItems = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecords(
        'root',
        'media',
        { per_page: 20, page: 1 }
      )
    );
    

    4. Fetching All Taxonomies for a Post Type

    const taxonomies = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecords(
        'root',
        'taxonomy'
      )
    );
    
    const postTaxonomies = taxonomies?.filter(
      ( tax ) => tax.types.includes( 'post' )
    );
    

    5. Getting Site Settings (Special Base Entity)

    const site = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecord(
        'root',
        '__unstableBase'
      )
    );
    
    const siteName = site?.name;
    const homeUrl = site?.home;
    

    What happens internally?

    GET /?_fields=name,home,...
    

    6. Fetch menu items

    const menuItems = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecords(
        'root',
        'menuItem',
        { menus: selectedMenuId }
      )
    );
    

    7. Reading Global Styles Variations

    const styles = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecords(
        'root',
        'globalStyles'
      )
    );
    

    8. Inspecting Active Theme Info

    const themes = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecords(
        'root',
        'theme'
      )
    );
    
    const activeTheme = themes?.find( theme => theme.status === 'active' );
    

    9. Fetching Plugins for a Plugin Manager UI

    const plugins = useSelect( ( select ) =>
      select( coreDataStore ).getEntityRecords(
        'root',
        'plugin'
      )
    );
    
    getEntityRecord( 'root', 'plugin', 'woocommerce/woocommerce.php' ); // You can fetch a single plugin
    
    
  6. changed the title [-]Docs: Add detailed entity configuration reference to data-core documentation[/-] [+][DevHub] Docs: Add detailed entity configuration reference to data-core documentation[/+] on Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions