How to Create Custom Post Types in WordPress

website

Post types are a term used to describe different types of content on a WordPress site. The engine comes with 5 default types: posts, pages, attachments, navigation menus, and revisions. All of them are stored in the wp_posts table of the database and differ in the column named post_type.

Post types are a way to distinguish between different types of content in WordPress. For example, posts and pages are both types of posts, but they are created for different purposes (see What is the difference between posts and pages in WordPress).

Along with post types, WordPress also has the concept of taxonomies. Taxonomies are used as a way to group posts.

WordPress comes with two default taxonomies: categories and tags. They are also different (see What is the difference between tags and categories). However, in some cases, you need to go beyond categories and tags. WordPress allows you to create your own taxonomies and use them in your post types to group and sort content.

Why create a custom post type or taxonomy?

You can theoretically add any type of content to WordPress posts and sort them by categories and tags. But sometimes this is inconvenient or illogical. Here are some signs that you need to create your own post type, taxonomy, or both.

  • The content you post on your site does not look like a publication (e.g., coupons in an online store).
  • There is no chronological order of publications (for example, an alphabetically sorted dictionary).
  • Categories and tags cannot group and sort specific content.
  • You need additional fields in posts or on pages to enter additional information.
  • You need to display specific content differently than in posts or pages.

Let’s look at a real-life example. Suppose you run a blog where, among other things, you regularly publish movie reviews that are very popular. You may want to add additional features to your movie reviews, such as ratings, make them searchable by actor names, genres, etc. In this case, it would be a good idea to create your own post type for movie reviews and add taxonomy to sort them by genre and actor.

Another example is creating a portfolio on the website of an artist, photographer, or musician. In addition to text content, you can create a separate section with convenient display and sorting of your works.

How to create a custom post type in WordPress?

There are two ways to create a custom post type and its taxonomies: using a plugin and manually. Let’s look at both methods.

Creating a custom post type using the Custom Post Type UI plugin

The first thing you need to do is install and activate the Custom Post Type UI plugin. After that, a new CPT UI item will appear in the admin menu.

WordPress admin menu

To create a new custom post type, go to CPT UI -> Add/Edit Post Types.

In the Post Type Slug field, enter the name of the new post type. It must contain Latin letters and numbers. Other characters are not allowed.

In the next field (Plural Label), enter a label for your custom post type. This name will be displayed in the WordPress admin panel, such as Posts or Pages. Therefore, it is better to specify it in the plural form.

The Singular Label option represents the singular form for your post type. This name will be used by WordPress to display instructions and other user interface elements.

You can also add a description (Post Type Description) for the new type (optional).

Now you can click the Add Post Type button to add your new post type.

All other values in the Additional Labels block are needed to display elements of the new type when performing operations with it in the admin panel (adding, deleting, viewing, sorting, etc.).