Skip to content

Taxonomy Labels

Carlos Moreira edited this page Jun 2, 2020 · 1 revision

The labels parameter will contain all messages and texts that will display when managing your Taxonomy in the administration. If you don't include this parameter, the framework will create these labels based on the name parameter of your taxonomy model.

We recommend you use at least the has_one and has_many parameters:

return [
	'type'         => 'tag',
	'name'         => 'country',
	'labels'       => [
		'has_one'  => 'Country',
		'has_many' => 'Countries',
	],
	'associations' => [
		'book',
		'post',
	],
];

With those two values the framework will build all labels for you.

However you can have more granular control over the labels, using the overrides argument to pass new labels:

return [
	'type'         => 'tag',
	'name'         => 'country',
	'labels'       => [
		'has_one'  => 'Country',
		'has_many' => 'Countries',
		'overrides' => [
			'labels' => [
				'menu_name' => 'Places',
			]
		],
	],
	'associations' => [
		'book',
		'post',
	],
];

See accepted values for the labels overrides in the documentation page for the get_taxonomy_labels() WordPress function.