Wordpress has this pretty well covered.
Enable the nested docs plugin
https://github.com/payloadcms/plugin-nested-docson a
categoriescollection then use a relationship field to reference the category
Here's an example
categoriescollection
{
slug: 'categories',
name: 'Categories',
fields: [
{
name: 'name',
type: 'text',
}
]
}Then in your Payload config, call the plugin
import nestedDocs from '@payloadcms/plugin-nested-docs'
export default buildConfig({
...
nestedDocs({
collections: ['categories'],
}),
})Then in a
postscollection, use a relationship field
{
slug: 'posts',
name: 'Posts',
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'categories',
type: 'relationship',
hasMany: true,
relationTo: 'categories',
}
]
}This would enable something like
News > Politics > United StatesOh lol, I thought docs stood for documentation, unfortunate naming đ
Thanks, will check it out!
Ahh makes sense. The original concept was actually ânested pagesâ but since this pattern applies to collections of any type ânested docsâ made the most sense
Star
Discord
online
Get dedicated engineering support directly from the Payload team.