wickywills
8/15/2017 - 9:05 AM

Create new custom post type with Lumberjack

Create new custom post type with Lumberjack

Create new PHP file within /themes/lumberjack/src/PostTypes/ with the name of your new post type e.g. Cars.php (note the case). Within this file, add the following:

<?php

namespace Lumberjack\PostTypes;

class Cars extends Post
{
    protected static $postType = 'cars';
}

Then head over to /themes/lumberjack/src/Config/CustomPostTypes.php, and under the function types(), add something like the following (similar to the standard way of adding a new post type in Wordpress):

// Cars
register_post_type(
    Cars::postType(),
    [
        'labels' => [
            'name' => __('Cars'),
            'singular_name' => __('Car')
        ],
        'public' => true,
        'has_archive' => false,
        'hierarchical' => false,
        'supports' => [
            'title'
        ],
        'rewrite' => [
            'slug' => 'cars',
        ],
        'show_in_nav_menus' => true,
        'taxonomies' => [
            // 'category'
        ]
    ]
);