Events and they will all be separate from each other. Each with its own set of fields and settings. We’ll go over the basics of post types and how to create custom post types.
Built-in Post Types
WordPress comes with 3 built-in post types:post, page and attachment.
Posts are usually meant for articles. Pages are used for content like About or Contact Us. Attachments are used for media files. Everytime you upload a file to WordPress, it creates an attachment post.
Even though WordPress supports these three different content types, under the hood, all of them are stored in the same database table. The differences between them are based on the features they support and the possible ways to retrieve them.
When architecting a site, have the arguments for register_post_type() in front of you, as well as the list of post type features. Consciously decide which capabilities that the different post types need to support, and which not.
Keep in mind that once you decide to give a capability to a content type, it will apply to all entities of this type. Imagine that you have a post type and you registered archive support. It will be difficult to exclude individual posts from this archive (there are possible approaches, but they all have important drawbacks).
This is because every post type argument and feature comes with a fixed set of expectations. As an example if a post type supports authors, it will show up in author archives. While it is possible to remove individual post types from individual archives, this can be ineffective, or even impossible.
The decision on whether to use a built-in WordPress feature and customise it, or whether to write something from scratch is not always clear from the start. In such a case, it can be useful to build a quick MVP to validate or refute a possible architecture.
Registering a new Custom Post Type
To register a new post type, you can use theregister_post_type() function. This function takes two parameters: the post type name and an array of arguments. We register all post types in plugins. One plugin per post type.
You can create new post types by using our Post Type Plugin Generator but you can also find a sample plugin file below.
Please remember to replace
PREFIX with your own project prefix and replace textdomain with your own text domain.PluginName.php