CPT stands for Custom Post Type. WordPress uses posts as a way of storing various pieces of content. This content can then be used in lots of different ways. Even though they are referred to as posts, they can be used for anything that requires content to be stored, changed and removed. WordPress uses multiple post types for some basic functionality.
By default you have WordPress posts and these form the basis of any WordPress blog. WordPress also uses built-in post types to manage menus, attachments, revisions and pages.
So what is a custom post type?
Custom post types are specific post types that have been added to WordPress using custom code or plugins. The idea is that you may want to add additional functionality to your site but don’t want to add everything as a standard post.
Imagine you would like to add in a section to your website for your team members. You could build a custom page for this but then you would need to edit that page to add or remove any new team members. This can become difficult to manage and time-consuming. By creating a custom post type instead, you create an interface for adding new team members that are automatically inserted into a template designed for that content.
Custom post types are great because they give developers and site managers a way of adding new functionality and content without having to handle complex coding every time.
The basic part of any custom post type is the post itself. When you create your Team post type you will get a new menu item, just like Posts, Media and Pages. This makes it easy to see the content of your teams separately.
From there you can add, edit and remove any team members easily from a familiar admin interface.
It is really useful to create a new post type but on its own you could only add a title, text and very little else. Let’s take a look at some of the tools available to enhance a custom post type and make it easily customisable for any purpose.
Taxonomies give you a way of grouping content. The categories and tags on a standard WordPress Post are different types of taxonomies. The actual categories and tags are called terms.
By using taxonomies or creating new ones you can start to enhance your post type and make grouping content very easy. If you team had various departments or skills you could add those as taxonomies. That way, when you assign them to each member in the post type you would be able to pull that information out and use it in your site and theme in various ways.
Custom fields are another great way to enhance any post type or custom post type. A custom field allows you to add virtually any additional information you would like. A standard field would be the title or the description of a post or page. These are stored separately in your site so they can be easily used at a later point in your theme.
If you wanted to enhance your Team post type with additional information such as a person’s job title or qualifications then you could create a custom field for this.
Custom fields can be added to all post types and custom post types. There are various tools and plugins available to help add custom fields to your WordPress site. Many of these tools like Advanced Custom Fields make it easy to create custom fields without using any code until you want to display it on your site.
Theming and plugins
Custom post types are vital when it comes to theme customisation. Very often themes will add additional post types to power the various custom parts of the theme. Not only can the theme add custom post types but they can also be added with plugins.
Sometimes plugins that create custom post types are a better option in the long run. If your Team post type was added to the theme and you decided to change the theme later, than you would lose it. The benefit of a plugin is that you can leave the plugin in place and still change the theme so you don’t lose that functionality.