Skip to content
  1. Blog

Announcing Acorn Post Types

Ben Word 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.

Discuss this post on Roots Discourse

About the author

Ben Word

Ben Word has been creating WordPress sites since 2004. He loves dogs, climbing, and yoga, and is passionate about helping people build awesome things on the web.

Subscribe for updates

Join over 8,000 subscribers on our newsletter to get the latest Roots updates and tips on building better WordPress sites

Looking for WordPress plugin recommendations, the newest modern WordPress projects, and general web development tips and articles?

One last step! Check your email for a verification link.