Tutorial

Post Types in WordPress

WordPress has evolved from a blog tool and now it is able to manage any kind of content.

Content in WordPress

WordPress stores data in a database. At the time of this writing, only MySQL and MariaDB database engines are supported. The table wp_posts of the database stores information about each post. Some fields in this table are:

  • ID —numeric identifier of the post
  • post_content —content of the post
  • post_title —title of the post
  • post_status —status of the post
  • post_type —post type identifier

The field post_type indicates the post type of the post. Post types are a way to refer to each type of content on a WordPress website. By default, WordPress comes with post types like Post, Page, and Attachment; but you can create other post types according to your needs.

Post types available by default are called “built-in post types” or “default post types”, and user-defined post types are called “custom post types”.

Built-in post types

The most known built-in post types are Post, Page, and Attachment. There are other built-in post types, which are used internally by WordPress.

Use posts when the chronological order of the content is relevant. This post type is very used in blogs, where newer posts appear generally first.

Use pages when the chronological order is not relevant, such as in the case of the About and Contact pages of a website, because both pages are normally displayed outside any time-based listing.

An attachment holds information about a file uploaded to the Media Library.

Custom post types

Use custom post types when your website requires a level of customization that cannot be achieved using the default post types. This is a powerful feature that has extended WordPress beyond a blog tool.

Example: A website to manage the collection of books in a bookstore. For each book, the website should manage information like title, author, year, summary, ISBN, editorial, and price. The website should also allow searching books using any field.

The professional solution for this problem is to register a custom post type, Book is a good name. If the website should also manage magazines, simply register another post type for this purpose.

Learn here how to register a custom post type in WordPress.

Further reading

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

WordPress

Related Tutorials