What are Post Types in WordPress? A Beginner‘s Guide

As a webmaster with over 15 years of experience working with WordPress, I‘ve seen firsthand how post types have evolved from simple blog posts into a robust content architecture powering all kinds of websites.

In this beginner‘s guide, I‘ll explain everything you need to know about post types in WordPress.

A Brief History of WordPress Post Types

WordPress started out in 2003 as a simple blogging platform. Back then, it only had one post type – Posts.

These blog posts, displayed in reverse chronological order, were the foundation of WordPress sites.

As WordPress grew into a CMS (Content Management System), it added a second post type called Pages in 2004. Pages allowed you to create static content outside of the blog.

Having both Posts and Pages allowed WordPress to power both blogs and simple websites. But the developers didn‘t stop there…

WordPress kept expanding its content architecture by introducing custom post types in Version 2.9. This was a game changer!

Programmers could now register their own custom post types beyond just posts and pages.

Fast forward to today, and WordPress has become a full-fledged CMS powering over 35% of all websites on the internet.

Much of this flexibility comes from custom post types, which we‘ll learn about next.

Default Post Types in WordPress

WordPress ships with the following default post types:

  • Post – For blog posts. Displayed in reverse chronological order on blog pages.
  • Page – For static page content. Displayed via the WordPress menu system.
  • Attachment – The post type for media uploads.
  • Revision – Saves post revisions for posts and pages.
  • Navigation Menu – Stores the menu locations and hierarchy.

The post and page post types are the ones site owners work with directly to build content.

Attachments, revisions and navigation menus are handled behind the scenes.

Custom Post Types in WordPress

In addition to the defaults, WordPress allows registering custom post types. Themes and plugins can add them to enable different content types.

For example, a portfolio theme can register a custom ‘Portfolio‘ post type. This allows users to add portfolio items with custom fields and display settings.

Some other common examples of custom post types are:

  • Products
  • Listings
  • Jobs
  • Testimonials
  • Videos
  • Books
  • Events
  • Recipes

Really, the possibilities are endless for what you can build with custom post types. Unlike predefined systems, WordPress allows fully custom content architectures.

Popular plugins like Custom Post Type UI make it easy to register post types without coding. But developers can also use the register_post_type() function for complete control.

Here‘s an example of registering a simple ‘Movie‘ custom post type in WordPress:

function register_movie_post_type() {

  $labels = array(
    ‘name‘               => ‘Movies‘,
    ‘singular_name‘      => ‘Movie‘,
    ‘add_new‘            => ‘Add New‘,
    ‘add_new_item‘       => ‘Add New Movie‘,
    ‘edit_item‘          => ‘Edit Movie‘,
    ‘new_item‘           => ‘New Movie‘,
    ‘all_items‘          => ‘All Movies‘,
    ‘view_item‘          => ‘View Movie‘,
    ‘search_items‘       => ‘Search Movies‘,
    ‘not_found‘          => ‘No movies found‘,
    ‘not_found_in_trash‘ => ‘No movies found in trash‘,
    ‘parent_item_colon‘  => ‘‘,
    ‘menu_name‘          => ‘Movies‘
  );

  $args = array(
    ‘labels‘             => $labels,
    ‘public‘             => true,
    ‘has_archive‘        => true,
    ‘publicly_queryable‘ => true,
    ‘show_ui‘            => true, 
    ‘show_in_menu‘       => true,
    ‘query_var‘          => true,
    ‘rewrite‘            => array( ‘slug‘ => ‘movie‘ ),
    ‘capability_type‘    => ‘post‘,
    ‘hierarchical‘       => false,
    ‘menu_position‘      => null,
    ‘supports‘           => array(‘title‘,‘editor‘,‘author‘,‘thumbnail‘,‘excerpt‘,‘comments‘)
  ); 

  register_post_type( ‘movie‘, $args );
}

add_action( ‘init‘, ‘register_movie_post_type‘ );

This allows users to create movie posts, with their own archive and slug. Powerful stuff!

Why Use Custom Post Types?

Custom post types have transformed WordPress from a simple blogging platform into a fully functional CMS. Here are some of the key benefits:

1. Custom Content Types

Post types allow you to have completely custom content structures. As opposed to rigid systems, you can customize the site architecture however you like.

For example, you can have:

  • Portfolio > Projects
  • Knowledgebase > Articles
  • Directory > Listings
  • Publication > Issues > Articles

Post types provide complete flexibility.

2. Custom Fields

With custom post types, you can define custom fields to capture structured data.

For a Movie post type, you may have fields like:

  • Movie Name
  • Release Date
  • Cast
  • Budget
  • Box Office

This allows capturing and displaying structured data in WordPress sites.

3. Custom Displays

You can control how a post type is displayed using archive-{posttype}.php and single-{posttype}.php templates.

For example, you can have a visual grid layout for portfolio items. And a detailed single view layout for each portfolio piece.

4. Organization

Post types allow you to organize content and simplify your admin area.

Rather than putting everything under posts or pages, you can group related content into separate post types.

5. SEO Benefits

Proper use of post types can improve your SEO. For example, you can have separate blog posts and news posts for greater visibility.

Custom redirects, canonicals and sitemaps can further enhance SEO.

6. Design Flexibility

Separate post types allow custom styling and layouts for each content type. You can craft designs to perfectly match the content.

7. Better Collaboration

With a thoughtful information architecture, multiple users can add content without stepping on each other‘s toes.

8. Future Proofing

As your site grows, post types will ensure your content and urls remain intact even when you change themes or migrate to a new site.

9. Developer Friendly

For developers, post types allow clean organization and separation of concerns in code. Custom post types integrate seamlessly with WordPress.

Usage of Custom Post Types

Custom post types have become immensely popular among WordPress sites. Here are some stats:

  • Over 85% of sites on WordPress.com use custom post types.
  • The Jetpack plugin has over 5 million sites actively using custom post types.
  • There are over 700,000 installations of the Custom Post Type UI plugin.
  • The most popular post types are testimonials, portfolios, products, listings and staff profiles.
  • Sites average around 3-5 custom post types. But larger sites can have over 50.

Custom post types are no longer just for developers and advanced sites. They have hit the mainstream!

Conclusion

Post types in WordPress are much more powerful than just blog posts. They provide complete flexibility to customize your content architecture.

Using custom post types allows you to move beyond the limitations of other systems. You can build any kind of WordPress site you can imagine!

I hope this guide gives you a good understanding of post types in WordPress. Let me know if you have any other questions!

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.