Documentation

PostType
in package

PostType Module class.

Table of Contents

Properties

$action_hook  : ActionHook
ActionHook instance.
$args  : array<string|int, mixed>|null
An array of arguments for registering a post type.
$post_type  : string
Post type key.

Methods

__construct()  : mixed
Constructor.
__toString()  : string
Custom toString magic method.
register_post_type()  : void
Registers the post type with WordPress.
initialize()  : void
Initializes the post type.

Properties

$action_hook

ActionHook instance.

private ActionHook $action_hook

ActionHook object for the register_post_type method.

Tags
since
1.0.0

Methods

__construct()

Constructor.

public __construct(string $post_type, array<string|int, mixed> $args[, ActionHook $action_hook = null ]) : mixed

Constructs the PostType object by setting the post type key, arguments, and action hook.

Parameters
$post_type : string

Post type key. Must not exceed 20 characters and may only contain lowercase alphanumeric characters, dashes, and underscores. See sanitize_key() .

$args : array<string|int, mixed>

Array or query string of arguments for registering a post type.

$action_hook : ActionHook = null

Optional. ActionHook instance. Default 'init'.

Tags
since
1.0.0

__toString()

Custom toString magic method.

public __toString() : string

Returns the post type as a JSON string.

Tags
since
1.0.0
Return values
string

JSON string.

initialize()

Initializes the post type.

private initialize() : void

Hooks the action to register the post type and adds the post type to the registry.

Tags
since
1.0.0

        
On this page

Search results