Skip to main content
3 of 5
added 287 characters in body

How to return a list of custom taxonomy terms via the Gutenberg getEntityRecords method

This method for "How would I get a taxonomy/category list inside a Gutenberg block?" at URL: How would I get a taxonomy/category list inside a Gutenberg block? does NOT work for custom taxonomies, e.g.:

wp.data.select('core').getEntityRecords('taxonomy', 'my-custom-taxonomy', {per_page: -1})

and only returns null, whereas the core category, i.e. "category", returns:

wp.data.select('core').getEntityRecords('taxonomy', 'category', {per_page: -1})

returns an entire array of taxonomy term data such as:

  • count
  • description
  • id
  • link
  • meta []
  • name
  • parent
  • slug
  • taxonomy etc.

The official docs at: https://developer.wordpress.org/block-editor/data/data-core/#getEntityRecords are woefully lacking, and whilst there are references to the "getEntityRecords" in GitHub at e.g.: https://github.com/WordPress/gutenberg/blob/04e142e9cbd06a45c4ea297ec573d389955c13be/packages/core-data/src/entities.js there is little in the way of documentation to help!

So here is the question:

How can you return the list of custom taxonomies using the wp.data.select('core').getEntityRecords method?

OR do you need to create a custom store, or use the wp.data Backbone JS?