I've gone through the documentation and the source code but I couldn't understand.

I have 2 queries:

getEntityRecords( 'postType', 'post' ); and getEntityRecords( 'root', 'user' ).

  1. Why does the 2nd query require root as the 1st argument?
  2. What does it mean?
  3. How to determine when to use it?

The doc describes the parameters of getEntityRecords as following:


  • state Object: State tree
  • kind string: Entity kind.
  • name string: Entity name.
  • query ?Object: Optional terms query.
  1. Are postType and root both state trees?
  2. How does state relate to kind while referring to entities.js?

1 Answer 1


The important thing to note is that post is a kind/sub-type of the post types entity, all posts regardless of type share the same table and general data structure and fields etc.

This contrasts with other major entity types such as comments or users.

However, what if there is no kind or sub-type? What if your entity is a user? What would you put as the entity kind/sub-type? There is only 1 kind of user! So you go one level up, and that's where root comes from.

It's also useful to know that entities are very related to the REST API and endpoints, and that this is the only connection to the PHP side of things. Entities only exist in the WP javascript packages. It's possible to use the REST API and javascript without referring to entities on the frontend, but if you're working with the block editor it's highly relevant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.