Plugin API Reference
Meta Box API
Add custom fields UI panels to the post editor. Meta boxes appear as collapsible panels on the post create/edit screen and store key-value metadata alongside posts.
📍 Source: App\CMS\MetaBoxes\MetaBoxRegistry
Registering a Meta Box
use App\CMS\MetaBoxes\MetaBoxRegistry;
public function boot(): void
{
MetaBoxRegistry::register('announcement_options', [
'title' => 'Announcement Options',
'post_types' => ['announcement'],
'context' => 'side', // 'normal', 'side', or 'advanced'
'priority' => 'default', // 'high', 'default', or 'low'
'fields' => [
[
'key' => 'is_pinned',
'label' => 'Pin this announcement',
'type' => 'checkbox',
],
[
'key' => 'expiry_date',
'label' => 'Expiry Date',
'type' => 'date',
'default' => null,
],
[
'key' => 'priority_level',
'label' => 'Priority',
'type' => 'select',
'options' => [
'low' => 'Low',
'normal' => 'Normal',
'high' => 'High',
'urgent' => 'Urgent',
],
'default' => 'normal',
],
],
]);
}
Method Signature
MetaBoxRegistry::register(string $id, array $options): void
Options Reference
| Key | Type | Description |
|---|---|---|
title | string | Display title for the meta box panel |
post_types | array | Post type slugs where this box appears |
context | string | 'normal', 'side', or 'advanced' |
priority | string | 'high', 'default', or 'low' |
fields | array | Array of field definitions (see below) |
Field Types
| Type | Rendered As | Extra Keys |
|---|---|---|
text | Text input | placeholder |
textarea | Textarea | rows |
checkbox | Checkbox | — |
select | Dropdown select | options (key => label array) |
date | Date picker input | — |
number | Number input | min, max, step |
color | Color picker | — |
image | Image upload/URL | — |
Reading & Writing Post Meta
// Read a meta value
$isPinned = $post->getMeta('is_pinned', false);
$expiryDate = $post->getMeta('expiry_date');
// Write a meta value
$post->setMeta('is_pinned', true);
$post->setMeta('priority_level', 'urgent');
// Bulk read all meta for a post
$allMeta = $post->getAllMeta();
💡 Tip: Meta values are stored as key-value pairs in the post_meta table. The core automatically saves meta box field values when the post is saved from the admin editor.
Last verified against AIPostify core. © 2026 AIPostify Marketplace Developer Documentation.