Registering custom post types

Post types allow you to easily create and manage various content structures.

They should be registered inside app/Structure/posttypes.php file within init action. Starter registers book post type as an example. Customize it to your needs.

namespace Tonik\Theme\App\Structure;

use function Tonik\Theme\App\config;

function register_book_post_type()
{
  register_post_type('book', [
    'description' => __('Collection of books.', config('textdomain')),
    'supports' => ['title', 'editor', 'excerpt', 'thumbnail'],
    'public' => true,
  ]);
}
add_action('init', 'Tonik\Theme\App\Structure\register_book_post_type');
Spotted a mistake or want to contribute to the documentation? Edit this document on Github!