custom-post-types

Configure your custom post types and their options pages, all from a single array.

Usage

KeyTypeRequiredDefault
"custom-post-types"arrayNo[]

Where the array contains a list of associative arrays with the options below:

Custom Post Type Object

KeyTypeRequiredDescription
"slug"stringYesPost type slug, used as an identifier
"icon"stringNoA dashicon to display in menus
"taxonomies"arrayNoA string array of taxonomy identifiers to register for this post type
"disable"arrayNoA string array of features to disable
"options-pages"arrayNoA string array of options pages to add to this post type, using this syntax
"options"arrayNoAn associative array of options to create the post type with, where labels and rewrite options can be set

Options

The value of the "options" field is passed directly into the second parameter of WordPress’s register_post_type($name,$options) function, and uses these options.

To easily generate options for your custom post type, check out this website.

Disable Features

A list of possible features to disable using the "disabled" key

KeyDescription
"yoast"Disables the Yoast SEO plugin for just this post type

Example

Here is a custom post type for a TV Show with a genre taxonomy, custom labels, and an options page:

config.php
return [
"custom-post-types" => [
[
"slug" => 'shows',
"icon" => 'dashicons-format-video',
"options-pages" => ['show-archive-settings'],
"taxonomies" => ['genre'],
"disable" => ['yoast'],
"options" => [
"has_archive" => 'shows',
"show_in_nav_menus" => true,
"supports" => ['title', 'editor', 'thumbnail'],
"rewrite" => [
'slug' => 'shows',
'with_front' => true,
'pages' => true,
'feeds' => true,
],
"labels" => [
'name' => _x('TV Shows', 'Post Type General Name', 'text_domain'),
'singular_name' => _x('TV Show', 'Post Type Singular Name', 'text_domain'),
]
]
],
]
]
A new custom post type with the slug "shows"