Announcing Acorn Post Types
Ben Word
on
WordPress the native registration process for custom post types and taxonomies feels disconnected from modern development practices. While libraries like Extended CPTs have made significant improvements to the developer experience, there’s still room for a more elegant, Laravel-inspired approach.
Introducing Acorn Post Types — a new package extracted from Radicle, our WordPress boilerplate, that allows you to configure custom post types and taxonomies through a straightforward PHP config file.
Usage
$ composer require roots/acorn-post-types
Once installed, you can publish the configuration file:
$ wp acorn vendor:publish --provider="Roots\AcornPostTypes\AcornPostTypesServiceProvider"
Post types and taxonomies are configured using a simple array structure in config/post-types.php
:
<?php
return [
/*
|--------------------------------------------------------------------------
| Post Types
|--------------------------------------------------------------------------
|
| Post types to be registered with Extended CPTs
| <https://github.com/johnbillion/extended-cpts>
|
*/
'post_types' => [
'seed' => [
'menu_icon' => 'dashicons-star-filled',
'supports' => ['title', 'editor', 'author', 'revisions', 'thumbnail'],
'show_in_rest' => true,
'names' => [
'singular' => 'Seed',
'plural' => 'Seeds',
'slug' => 'seeds',
],
],
],
/*
|--------------------------------------------------------------------------
| Taxonomies
|--------------------------------------------------------------------------
|
| Taxonomies to be registered with Extended CPTs library
| <https://github.com/johnbillion/extended-cpts>
|
*/
'taxonomies' => [
'seed_category' => [
'post_types' => ['seed'],
'meta_box' => 'radio',
'names' => [
'singular' => 'Category',
'plural' => 'Categories',
],
],
],
];
Acorn Post Types will automatically register your custom post types and taxonomies using the Extended CPTs library.