Post Types in WordPress
Post Types
- There are many different types of content in WordPress. A records content type is described as its Post Type. For example, a regular WP post record has the specific Post Type
post, and a page record has thepagePost Type. Internally, all of the types of content are stored in the same place — in thewp_postsdatabase table, but are differentiated by a database column calledpost_type. - By default the WordPress Template Hierarchy tries to match the Post Type of the record to a specific theme file to display on the front-end of the website. However, custom logic in template files can override how pages are constructed.
- The add_post_type_support() function can be used to add support for various WordPress features to specific (default or custom) post-types. For example, by default the Page post type does not support excerpts, but by using
add_post_type_support()you can add support. - Custom Post Types can be defined using the
register_post_type()function from within thefunctions.phpfile. - Post Types (wordpress.org/documentation)
- Post Types (developer.wordpress.org)
- Smashing Magazines Complete Guide To WordPress Custom Post Types
Types of Posts
There are five Post Types available by default in the WordPress:
| Post Type | slug | Description |
|---|---|---|
| Post | post |
The post post type is typically used for blogs. A list of posts are normally displayed in a blog in reverse sequential order by time (newest posts first). Posts are also used for creating RSS feeds. |
| Page | page |
A page is similar to posts however they have some very important differences. Pages aren’t displayed in a reversed time-based order. They can also be placed into a hierarchical order where a page can be the parent or child of another page creating a page structure. Traditionally, pages also do not make use of categories and tags like posts do. |
| Attachement | attachment |
Attachments are another post type that is special as these hold information about any media that is uploaded to your WordPress website. Not only is the main post information stored where other posts are, attachments also make use of the wp_postmeta table for storing extra information like metadata for images and videos that you’ve added. |
| Revision | revision |
Revisions are a particularly special post type as they are used to create a history of other post types in case you make a mistake and want to rollback to a previous version. Whilst you technically can’t edit revisions directly unless you restore a revision, they are editable just like posts and are stored in the wp_posts table like any other post type. |
| Navigation menu | nav_menu_item |
Menus (created by admin users in the admin panel) are lists of links that can be used to navigate your website. This allows admins to create custom lists of links to various locations on the website and are edited in the theme section of the dashboard. |