Wordpress has this pretty well covered.
Enable the nested docs plugin
https://github.com/payloadcms/plugin-nested-docson a
categories
collection then use a relationship field to reference the category
Here's an example
categories
collection
{
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
posts
collection, 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 States
Oh 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 help straight from the Payload team with an Enterprise License.