Tutorial

How to Register a Custom Post Type Using a Plugin in WordPress

Post types are a way to refer to each type of content on a WordPress website.

Background

WordPress comes by default with post types like Post, Page, and Attachment; and provides the function register_post_type to create other post types. This function is easy to use, but the process is even easier using a post type registration plugin.

Custom Post Type UI

Custom Post Type UI is a leader plugin for post type registration in WordPress.

Step 1: Install and activate the plugin Custom Post Type UI.

Step 2: Navigate to CPT UI > Add/Edit Post Types, enter the parameters of the new post type, and click the Add Post Type button.

Screen "Add/Edit Post Types" of the plugin Custom Post Type UI.

Advanced Custom Fields

Advanced Custom Fields is a leader plugin in the WordPress ecosystem. It was originally thought for custom fields, but later added support for custom post types and custom taxonomies.

Step 1: Install and activate the plugin Advanced Custom Fields.

Step 2: Navigate to ACF > Post Types and click Add New.

First step of the procedure to register a custom post type using Advanced Custom Fields.

Step 3: Enter the parameters of the new post type and click the Save Changes button.

Second step of the procedure to register a custom post type using Advanced Custom Fields.

Attributes

The list of attributes of a post type is large. You can find a detailed explanation of each one in the PHPDoc of the function register_post_type and in the official documentation.

Keep in mind that the identifier of a post type:

  • Must not exceed 20 characters
  • Should be prefixed to avoid conflicts
  • Should only contain lowercase alphanumeric characters, underscores, and dashes

Further reading

I recommend the other tutorials in this series to learn more about post types in WordPress.

WordPress

Related Tutorials