Taxonomies
in package
Taxonomies Registration class.
Facilitates the batch registration of custom taxonomies, streamlining their setup and association with post types. Utilizes the Taxonomy module for each taxonomy's registration, ensuring that taxonomies are added in accordance with WordPress standards and best practices.
Tags
Table of Contents
Methods
- set() : void
- Registers multiple custom taxonomies in bulk.
Methods
set()
Registers multiple custom taxonomies in bulk.
public
static set([array<string|int, mixed> $taxonomies = [] ]) : void
This method simplifies the process of registering custom taxonomies by accepting an array of taxonomy definitions. Each definition specifies the taxonomy's key, the object types it is associated with, and an array of arguments for customizing the taxonomy.
Example usage:
Taxonomies::set([
[
'taxonomy' => 'genre',
'object_type' => ['post'],
'args' => [
'hierarchical' => true,
'labels' => [
'name' => __('Genres', 'text-domain'),
'singular_name' => __('Genre', 'text-domain'),
// Additional labels...
],
'show_ui' => true,
// Additional taxonomy arguments...
],
],
...
]);
Parameters
- $taxonomies : array<string|int, mixed> = []
-
An array of custom taxonomy definitions. Each definition is an associative array that includes 'taxonomy', 'object_type' (array of post types), and 'args' for the taxonomy arguments.