Post Types in WordPress

Post Types in WordPress

Post Types

WordPress can display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Internally, all the post types are stored in the same place, in the wp_posts database table, but are differentiated by a column called post_type.

WordPress gives you the capability to add your own custom post types and to use them in different ways.

Default Post Types

There are several post types that are readily available by the WordPress installation by default :
Post (Post Type: ‘post’)
Page (Post Type: ‘page’)
Attachment (Post Type: ‘attachment’)
Revision (Post Type: ‘revision’)
Navigation Menu (Post Type: ‘nav_menu_item’)
Custom CSS (Post Type: ‘custom_css’)
Changesets (Post Type: ‘customize_changeset’)

Post in WordPress is a post type that is typical for and most used by blogs. Posts are normally displayed in a blog (newest posts first). Posts are also used for creating the feeds.

Page in WordPress is like post, but it lives outside the normal time-based listings of posts. Pages can use different page templates to display them. Pages can also be organized in a hierarchical structure, with pages being parents to other pages, but they normally cannot be assigned categories and tags.

Attachment is a special post that holds information about a file uploaded through the WordPress media upload system, such as its description and name. For images, this is also linked to metadata information, stored in the wp_postmeta table, about the size of the images, the thumbnails generated from the images, the location of the image files, the HTML alt text, and even information obtained from EXIF data embedded in the images.

Revision is used to hold a draft post as well as any past revisions of a published post. Revisions are basically identical to the published post which they belong to, but have that post set as their parent using the post_parent column of the wp_posts table.

Navigation Menu
Navigation Menu is a type that holds information about a single item in the WordPress navigation menu system. These are the first examples of entries in the wp_posts table to be used for something other than an otherwise displayable content on the blog.

Custom CSS
Custom CSS is a theme specific post used to store CSS saved from The Customizer’s “Additional CSS” screen. Each theme could have their own post but only the active themes custom_css post is used when displaying the theme.

Changesets is similar to auto-saves but specifically for The Customizer. This is to keep The Customizer in a persistent state. WordPress will attempt to keep content changes made through The Customizer during the user session in a customize_changeset post and attempt to pull them back up should your cat close your browser.

Custom Post Types
Custom post types are new post types you can create. A custom post type can be added to WordPress via the register_post_type() function. This function allows you to define a new post type by its labels, supported features, availability and other specifics.

Note that you must call register_post_type() before the admin_menu and after the after_setup_theme action hooks. A good hook to use is the init hook.


You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *