cloud WordPress

How to create custom post types on WordPress

intermediate 10 min read Updated 2026-03-18
Quick Answer

Custom post types in WordPress can be created by adding code to your theme's functions.php file or using a plugin. You'll need to register the post type using the register_post_type() function with specific parameters.

Prerequisites

  • WordPress admin access
  • Basic PHP knowledge
  • Text editor or code editor
  • Active WordPress theme

Step-by-Step Instructions

1

Access your WordPress files

Navigate to your WordPress admin dashboard and go to Appearance > Theme Editor, or access your site files via FTP/cPanel. Locate your active theme's functions.php file. Alternatively, you can create a custom plugin file in the /wp-content/plugins/ directory.
Always create a child theme or backup your site before editing theme files to prevent losing changes during theme updates.
2

Add the custom post type registration code

Open the functions.php file and add the following code before the closing PHP tag:

function create_custom_post_type() {
    register_post_type('your_post_type',
        array(
            'labels' => array(
                'name' => 'Custom Posts',
                'singular_name' => 'Custom Post',
            ),
            'public' => true,
            'has_archive' => true,
            'supports' => array('title', 'editor', 'thumbnail'),
        )
    );
}
add_action('init', 'create_custom_post_type');
Replace 'your_post_type' with a unique slug for your custom post type (use lowercase letters, numbers, and underscores only).
3

Configure post type labels and settings

Customize the labels array to define how your post type appears in the admin area:

'labels' => array(
    'name' => 'Products',
    'singular_name' => 'Product',
    'add_new' => 'Add New Product',
    'add_new_item' => 'Add New Product',
    'edit_item' => 'Edit Product',
    'new_item' => 'New Product',
    'view_item' => 'View Product',
    'search_items' => 'Search Products',
    'not_found' => 'No products found',
    'not_found_in_trash' => 'No products found in trash'
),
Use descriptive labels that clearly indicate what type of content this post type will contain.
4

Set post type capabilities and features

Add additional parameters to control post type behavior:

'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'),
'menu_icon' => 'dashicons-products',
'menu_position' => 5,

Set 'show_in_rest' => true to enable Gutenberg editor support.
Visit the WordPress Dashicons page to find appropriate menu icons for your custom post type.
5

Save and refresh permalinks

Save the functions.php file and navigate to your WordPress admin dashboard. Go to Settings > Permalinks and click Save Changes without making any modifications. This flushes the rewrite rules and ensures your custom post type URLs work correctly.
Always flush permalinks after creating or modifying custom post types to avoid 404 errors on frontend pages.
6

Verify the custom post type appears

Check your WordPress admin sidebar - you should now see your new custom post type listed in the menu. Click on it to access the post management screen where you can Add New posts of your custom type. The interface will be similar to regular posts but with your custom labels.
If the post type doesn't appear, check for PHP syntax errors in your functions.php file and ensure the code is properly formatted.
7

Create template files for frontend display

To customize how your custom post type appears on the frontend, create template files in your active theme directory:
  • single-your_post_type.php for individual post display
  • archive-your_post_type.php for the archive page

Copy existing template files like single.php or archive.php and modify them as needed.
WordPress follows a template hierarchy - if custom templates don't exist, it will fall back to generic templates like single.php or index.php.

Common Issues & Troubleshooting

Custom post type doesn't appear in admin menu

Check that 'show_ui' => true and 'show_in_menu' => true are set in your registration code. Also verify there are no PHP syntax errors in your functions.php file.

404 errors when viewing custom post type pages

Go to Settings > Permalinks and click Save Changes to flush rewrite rules. Ensure 'public' => true and 'publicly_queryable' => true are set in your registration.

Custom post type posts don't show in frontend loops

By default, custom post types are excluded from main queries. Use pre_get_posts action or modify your queries to include custom post types using the 'post_type' parameter.

Gutenberg editor not working with custom post type

Add 'show_in_rest' => true to your post type registration arguments. This enables REST API support required for the Gutenberg editor.

Prices mentioned in this guide are pulled from current plan data and may change. Always verify on the official WordPress website before purchasing.