Content types
Post types
Register editor-ready content types using familiar WordPress arguments.
#Complete example
<?php
defined('ABSPATH') || exit;
use Voxyframe\Core\Registry;
add_action('voxycure/register', function (Registry $registry): void {
$registry->register_post_type('project', [
'name' => 'Projects',
'singular_name' => 'Project',
'show_in_rest' => true,
'supports' => ['title', 'editor', 'thumbnail'],
]);
});#Definition arguments
| Key | Type | Default / purpose |
|---|---|---|
name | string | Plural label derived from the slug. |
singular_name | string | Falls back to name. |
public | boolean | true |
show_ui | boolean | true |
show_in_rest | boolean | true; required for the block editor. |
supports | string[] | title and editor. |
has_archive | boolean|string | true |
rewrite_slug | string | The post type slug. |
args | array | Overrides or adds native WordPress arguments. |
#Pass current WordPress arguments
This is a complete inc/voxycure.php file. Put advanced native arguments inside args.
<?php
defined('ABSPATH') || exit;
use Voxyframe\Core\Registry;
add_action('voxycure/register', function (Registry $registry): void {
$registry->register_post_type('event', [
'name' => 'Events',
'args' => [
'rest_namespace' => 'wp/v2',
'template' => [['core/heading'], ['core/paragraph']],
'template_lock' => 'insert',
],
]);
});