PostTypes
in package
PostTypes Registration class.
Enables the batch registration of custom post types, simplifying the process of defining and managing unique content types within a WordPress theme or plugin. Utilizes the PostType module for each post type's registration, ensuring that each custom post type is registered according to WordPress standards and best practices.
Tags
Table of Contents
Methods
- set() : void
- Registers multiple custom post types in bulk.
Methods
set()
Registers multiple custom post types in bulk.
public
static set([array<string|int, mixed> $post_types = [] ]) : void
This method simplifies the registration of custom post types by accepting an array of post type definitions. Each definition specifies the post type's key, labels, supports array, and other arguments, allowing for comprehensive and flexible content type creation.
Example usage:
PostTypes::set([
[
'key' => 'custom_post_type',
'args' => [
'label' => __('Custom Post Type', 'text-domain'),
'public' => true,
'supports' => ['title', 'editor', 'thumbnail'],
// Additional custom post type arguments.
],
],
...
]);
Parameters
- $post_types : array<string|int, mixed> = []
-
An array of custom post type definitions. Each definition is an associative array that includes a 'key' for the post type identifier and 'args' for an array of arguments used to register the post type.