Skip to main content
April 1, 2026Noble Desktop Publishing Team/8 min read

Making Custom Post Types

Master WordPress Custom Post Types and Taxonomies

Core WordPress Concepts

Custom Post Types

Create specialized content types beyond standard posts and pages. Essential for complex CMS functionality and organized content management.

Taxonomies

Classification systems that organize your content using categories and tags. Enable powerful content filtering and organization.

Theme Functions

PHP functions that extend WordPress functionality. Central hub for customizations and feature additions in functions.php.

Topics Covered in This WordPress Tutorial:

Adding Thumbnail Support (post-thumbnails), Creating a Custom Post Type, Registering Taxonomy

Tutorial Prerequisites

0/3

Exercise Preview

ex prev B6

WordPress Content Evolution

Before 2010

Pre-WordPress 3.0

Limited to pages and posts only, restrictive for complex CMS usage

2010

WordPress 3.0 Release

Introduced custom post types, enabling complex content management

Present

Modern WordPress

Full CMS capabilities with custom post types, taxonomies, and fields

Exercise Overview

Prior to WordPress 3.0's release in 2010, developers were constrained to using only pages and posts for content management. This limitation severely hindered WordPress's potential as a comprehensive content management system, relegating it primarily to blogging applications. The introduction of custom post types in WordPress 3.0 revolutionized content organization, transforming WordPress into a truly flexible CMS platform that powers over 40% of the web today.

Custom post types unlock sophisticated content architecture possibilities. They feature dedicated Dashboard menus, customizable interface layouts, and granular content control that enables you to structure your site's information hierarchy precisely as your project demands. Whether you're building an e-commerce platform, portfolio site, or complex enterprise application, custom post types provide the foundation for scalable content management.

In this hands-on exercise, you'll construct a custom post type specifically designed for automotive content. This "Cars" post type will integrate seamlessly into your Dashboard workflow, allowing you to manage vehicle listings with the same intuitive interface you use for standard posts and pages. Additionally, you'll implement a custom taxonomy system to categorize cars by their sales status—whether they're actively for sale, already sold, or featured prominently. This taxonomy approach demonstrates how professional developers organize and filter content dynamically, a crucial skill for building sophisticated WordPress applications.

Project Implementation Steps

1

Create Cars Post Type

Register a custom post type called 'cars' with appropriate labels and settings for automotive content management

2

Add Thumbnail Support

Enable post thumbnail functionality with specific dimensions (223x140 pixels) for car image displays

3

Register Status Taxonomy

Create a hierarchical taxonomy to classify cars as 'For Sale', 'Sold', or 'Featured'

4

Configure Dashboard Interface

Set up custom menu items and interface elements for managing car listings in WordPress admin

If You Did Not Do the Previous Exercise

  1. In a web browser, go to localhost:8888/lamdm/wp-admin (Mac) or localhost/lamdm/wp-admin (Windows) and log in if prompted.
  2. On the left of the Dashboard, mouse over Appearance and click Themes.
  3. Click the Add New button.
  4. Click the Upload link, then the Browse (or Choose File) button.
  5. Navigate to Desktop > Class Files > WordPress.org Class and double–click landmTheme-ready-for-custom-post-types.zip to open it.
  6. Click Install Now, then click Activate.

Registering a Custom Post Type

Custom post types must be registered through WordPress's functions.php file to integrate properly with the core system. This registration process tells WordPress how to handle your custom content type, defining its behavior, capabilities, and Dashboard presentation. Let's begin by implementing the foundational code structure.

  1. Switch to your code editor.

  2. Open functions.php from the landmTheme folder (will be landmTheme-ready-for-custom-post-types if you didn't do the previous exercise).

  3. At the end of functions.php, just before the closing ?>, add the following:

    /* Add support for thumbnails */
    
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 223,140, true );

    The add_theme_support() function activates WordPress's built-in featured image functionality for your theme. The set_post_thumbnail_size() function establishes standardized dimensions for thumbnail generation—in this case, 223 x 140 pixels with hard cropping enabled. This ensures consistent image presentation across your automotive listings, which is crucial for professional-looking inventory displays. The hard crop parameter (true) maintains exact dimensions by cropping excess image area rather than distorting proportions.

  4. At the end of functions.php, just before the closing ?>, add the following:

    /* Registering the Cars custom post type */
    
    add_action( 'init', 'create_post_type' );
    function create_post_type() {
          register_post_type();
    };

    This code establishes the WordPress hook system integration for your custom post type. The add_action() function connects your create_post_type() function to WordPress's init action hook, which fires after WordPress completes its core loading sequence but before generating any output. This timing ensures your custom post type is available throughout the entire request lifecycle. The register_post_type() function currently lacks arguments, which we'll address in the next steps to define your post type's specific characteristics and capabilities.

  5. To save some time, we have already typed up the arguments for you. Open arguments.txt from the Class Files > WordPress.org Class > landm Content folder.

  6. Select all the code and copy it.

  7. Hit Cmd–W (Mac) or CTRL–W (Windows) to close the file but not the folder.

  8. Switch back to functions.php if you're not already there.

  9. Click inside the parentheses of register_post_type().

  10. Hit Return (Mac) or Enter (Windows) twice to add some space between the parentheses.

  11. In the new line you just added, paste in the arguments. It should look like the following (you may need to clean it up a bit so the indentation is easier to read):

    function create_post_type() {
          register_post_type(
             'cars', 
             array(
             'labels' => array( 
                         'name' => __('Cars'), 
                         'singular_name' => __('Car'), 
                         'add_new_item' => __('Add New Car'), 
                         'edit_item' => __('Edit Car'), 
                      ), 
             'public' => true, 
             'hierarchical' => false, 
             'rewrite' => array( 'slug' => 'cars'), 
             'supports' => array('title', 'thumbnail', 'editor', 'excerpt', 'custom-fields', 'author')
             )
       );
    };

    The register_post_type() function accepts two critical parameters: $post_type (the internal identifier) and $args (configuration array). The identifier 'cars' serves as WordPress's internal reference for this post type—choose identifiers carefully as they're difficult to change after content creation. The arguments array defines your post type's behavior and presentation:

    labels: Defines the human-readable text displayed throughout the WordPress admin interface. These labels appear in menus, buttons, and page titles, ensuring a consistent user experience.
    public: Controls visibility in both the admin Dashboard and frontend queries. Setting this to true makes your post type fully accessible and queryable. For internal-only post types, set this to false.
    hierarchical: Determines content structure behavior. False creates a post-like structure (flat, chronological), while true enables page-like parent-child relationships. Most custom post types work best as non-hierarchical.
    rewrite: Customizes the URL structure for your post type. This creates SEO-friendly permalinks like yoursite.com/cars/honda-accord instead of generic parameter-based URLs.
    supports: Enables specific editing features in the admin interface. This modular approach lets you include only the functionality your content type actually needs, creating cleaner editing experiences.
  12. Save the file.

  13. Now let's verify your custom post type integration with WordPress. Navigate to your local development environment:
    • Mac: localhost:8888/landm/wp-admin
    • Windows: localhost/landm/wp-admin

    Log in if necessary.

  14. Examine the left sidebar navigation—you'll notice a new "Cars" menu item. Hover over Cars to reveal the submenu options. This demonstrates how WordPress automatically generates admin interface elements based on your post type registration, providing the same professional experience as built-in post types.

    custom post menu

  15. Under Cars, click Add New to explore the editing interface.

    The interface looks professional and functional, but you'll notice an unnecessary Author module at the bottom. Since automotive listings don't typically require author attribution, let's refine the interface by removing this module.

  16. Return to functions.php in your code editor.

  17. In the supports parameter array, remove 'author' and its preceding comma so the line reads:

    'supports' => array('title', 'thumbnail', 'editor', 'excerpt', 'custom-fields')
  18. Save your changes.

  19. Return to the WordPress Dashboard.

  20. Navigate to Cars > Add New again.

  21. Confirm that the Author module has been removed, creating a cleaner, more focused editing experience tailored specifically for automotive content.

Functions.php Location

All custom post type registration must be done in your theme's functions.php file. This ensures the post type is available whenever the theme is active.

Key Registration Parameters

Labels Array

Defines how the post type appears in the WordPress admin interface. Includes singular, plural, and action-specific labels.

Public Setting

Controls visibility in the admin dashboard and frontend. Must be set to true for the post type to appear.

Supports Array

Specifies which meta boxes and features are available: title, editor, thumbnail, excerpt, custom fields.

Registering a Taxonomy

Taxonomies provide the organizational structure that transforms your custom post type from a simple content repository into a sophisticated, filterable system. While WordPress includes built-in taxonomies like categories and tags for posts, custom post types benefit from purpose-built taxonomies that reflect your specific content needs. For automotive listings, a status taxonomy enables dynamic content filtering—essential for creating "Featured Cars," "Available Inventory," and "Sold Vehicles" sections that update automatically based on your categorization.

  1. Return to functions.php in your code editor.

  2. At the end of functions.php, just before the closing ?>, add the following:

    /* Registering Custom Taxonomies */
    
    add_action( 'init', 'create_status_taxonomy' );
    
    function create_status_taxonomy() {
          register_taxonomy();
    }

    This follows the same hook pattern established for your custom post type registration. The create_status_taxonomy() function hooks into WordPress's init action, ensuring your taxonomy is available when WordPress processes queries and generates content. The register_taxonomy() function will define how your status system integrates with your Cars post type.

  3. Replace the empty register_taxonomy() function with the following complete implementation:

    function create_status_taxonomy() {
          register_taxonomy(
             'status', 
             array('cars'), 
             array(
                'label' => __('Status'), 
                'hierarchical' => true, 
             )
          );
    }

    The register_taxonomy() function requires three parameters for complete implementation. The first parameter, $taxonomy, establishes the internal identifier ('status'). The second parameter, $object_type, connects your taxonomy to specific post types through an array—in this case, array('cars'). This design allows taxonomies to work across multiple post types if needed. The final parameter defines taxonomy behavior:

    label: Sets the display name visible throughout the WordPress admin interface. This appears in meta boxes, admin menus, and management screens.
    hierarchical: Controls whether terms can have parent-child relationships (like categories) or remain flat (like tags). Hierarchical taxonomies enable nested organization structures for complex categorization needs.
  4. Save the file to register your new taxonomy with WordPress.

Hierarchical vs Non-Hierarchical Taxonomies

FeatureHierarchical (Categories)Non-Hierarchical (Tags)
StructureParent-child relationshipsFlat structure
InterfaceCheckbox selectionText input field
Use CaseOrganized classificationFlexible labeling
ExampleCar Status: For Sale > FeaturedKeywords: luxury, sedan, automatic
Recommended: Use hierarchical taxonomies for structured classification systems like the car status example in this tutorial.

Adding Taxonomies

With your custom taxonomy registered, it's time to populate it with the specific status terms that will drive your automotive site's content organization. These status categories will serve as the foundation for dynamic content filtering in future exercises, enabling you to create automatically updating sections for different types of vehicle listings.

  1. Navigate to your WordPress Dashboard.

  2. In the left sidebar, hover over Cars and click the newly available Status link. This demonstrates how WordPress automatically generates management interfaces for your custom taxonomies.

  3. Create your first status category by entering the following information:

    Name: For Sale
    Slug: for-sale
    Parent: None
    Description: Leave it blank
  4. Click the Add New Category button to create this status term.

  5. Repeat this process to create two additional status categories: Sold (slug: sold) and Featured (slug: featured). These three status types provide comprehensive coverage for typical automotive inventory management needs.

    Your custom post type and taxonomy system is now operational and ready for content creation. In the following exercise, you'll learn how to leverage these organizational tools to create dynamic, automatically filtered content displays that respond to your categorization choices.

Car Status Categories Structure

For Sale33%
Sold33%
Featured34%
Dynamic Content Strategy

These status taxonomies will enable dynamic page content in future exercises, allowing automatic filtering and display of cars based on their status classification.

Key Takeaways

1WordPress 3.0 introduced custom post types, transforming WordPress from a simple blog platform into a powerful content management system
2Custom post types require registration in functions.php using the register_post_type() function with specific parameters for labels, visibility, and supported features
3The add_theme_support('post-thumbnails') function enables thumbnail functionality, essential for visual content like car listings
4Taxonomies provide organized classification systems for custom post types, with hierarchical options behaving like categories and non-hierarchical like tags
5The register_taxonomy() function creates custom classification systems that can be applied to specific post types for better content organization
6Custom post types appear as separate menu items in the WordPress dashboard, providing dedicated interfaces for content management
7Proper parameter configuration in the supports array determines which meta boxes and features are available in the post editor
8Custom taxonomies enable dynamic content filtering and display, essential for building sophisticated content-driven websites

RELATED ARTICLES