The useTerms hook
The useTerms hook is the Next.js binding for the useFetchTerms.
The useTerms
hook returns terms for a given WordPress taxonomy.
Basic Usage
const {
data: { terms },
} = useTerms({ taxonomy: 'category' });
caution
You do not need to use useTerms
if you simply need to access the term object for a taxonomy archive page (e.g category archive). You should use the queriedObject
from the usePosts
hook. See usePosts docs for more details.