In Gutenberg, one can use the getEntityRecord selector to get the data of a term of a specific taxonomy by its term id:

// Get the category term with term id = 25
const term = useSelect( ( select ) =>
    select('core').getEntityRecord( 'taxonomy', 'category', 25 )

My question is, is there a way to get the data of a specific term by using the term slug instead of the term id? If so, how?


I think one could search for a given term slug with getEntityRecords:

select('core').getEntityRecords( 'taxonomy', 'category', { slug : 'my-slug' } )

by skimming through the endpoint reference that supports the slug query parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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