Create WordPress Custom Post Type Templates

With the standard WordPress post types, you can create blog posts, pages or attachment pages. These posts and pages follow similar formats, and they’re fine for the average WordPress user.

However, if you want to create efficient content for your website, you may find the default post types limiting, which is where custom post types come into play.

Custom post types are specialized content types that expand beyond standard posts and pages to better suit your specific needs. They’re customizable, meaning you can name them whatever makes sense for your content (like “Testimonials,” or “Team Members”) and design them with unique layouts and features. As different custom post types often serve different purposes, you’ll typically need to create separate templates for each one to properly display their unique content and structure.

In this post, let’s define what templates are in WordPress, and how to create a template for a custom post type.

What are custom post type templates?

Custom post type templates are PHP files that define how your WordPress custom post content appears on your site. WordPress provides several default template options for custom post types, including:

  • Single-{Post-Type}.php – Whenever a user requests a single post of a custom post type, WordPress uses the single-{Post-Type}.php template. For example, the template single-shoes_product.php is used for single posts of the custom post type shoes_product.
  • Archive-{Post-Type}.php – WordPress uses the archive template to display the archive page of the custom post type by default.
  • Search.php – When a visitor searches for a custom post type on your website, WordPress uses the search.php template to display the search results.
  • Index.php – If the 3 templates above are not displayed, the index.php file is used for the custom post type.

Custom post templates allow you to apply new layouts to your custom posts. WordPress uses the default files such as single.php, archive.php and index.php for your custom post types, unless you create your own custom post type templates.

When do you need custom post type templates?

With a custom post type template, you can create multiple custom posts at the same time. The following cases show when you should consider creating a custom post type template:

  • Custom post for coupons – More than 90% of customers use coupons when making purchases. Coupons work well as custom posts because they differ structurally from standard content-focused post types. A coupon post typically contains a brief product introduction and a clickable coupon code that customers can use to receive their discount.
  • WordPress Glossary – If you don’t explain these technical terms clearly to your audience, customers won’t buy. This is where glossaries come into play to help visitors learn about your products and services, as it’s difficult to create elaborate glossaries with standard post types.
  • Additional fields – Another good example is if you want to enter more information into your content, such as custom meta fields on multiple blogs. Instead of adding these custom fields post by post, which takes a lot of time, you can create a new template for a custom post type. All custom posts that use this template will contain the desired additional fields.

How to Create a Custom Post Type Template in WordPress

There are 2 ways to create templates for custom post types. You can either edit the single.php file or use the Templatic plugin.

Before diving into these solutions, let’s create a child theme first. This child theme allows you to modify and save edits separately without affecting the parent theme. What’s more, you won’t lose your changes once the parent theme is updated.

We will use Twenty Twenty-Five, WordPress’s latest default theme to show you how to create custom post type templates. If you are using this theme, you can get started right away. In case your WordPress site still applies a previous version, please update to this version to have full capabilities.

Creating a Child Theme

Follow these 5 steps to generate a child theme:

  1. Go to your theme directory
  2. Create a new folder
  3. Provide a name for the theme
  4. Add 2 new files style.css and functions.php
  5. Use the code below to set up these files
/*
Theme Name: Custom Post Type Template Example
Theme URI: https://passwordprotectwp.com
Description: An example theme utilizing custom post type templates
Author: Password Protect WordPress Team
Author URI: https://passwordprotectwp.com
Template: twentytwentyfive
Version: 1.0
*/

<?php
add_action( 'wp_enqueue_scripts', 'cptt_assets' );

function cptt_assets() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ));
}

Once done, the new child theme will be shown in the Appearance section of your WordPress admin. After generating the child theme, let’s create a custom post template.

Method 1: Edit single.php Files

If you don’t want to add any plugins to your WordPress site or you’ve already installed many and don’t want to add any more, this method is for you. Follow this 5-step guide to easily create a custom post type template:

  1. Go to GenerateWP
  2. Provide your custom post type name in the Name (Singular) and Name (Plural) boxes
  3. Enter a descriptive summary of the post type in the Description box
  4. Hit Update Code
  5. Copy the generated code and paste in your single.php file
create-custom-post-type-template-generatewp

Method 2: Create Custom Post Templates with Custom Post Type UI plugin

Custom Post Type UI provides a user-friendly interface for creating and managing custom post types without editing code. This approach is more accessible than manually editing single.php files as it eliminates the complexity of code generation.

Step 1: Install the Plugin

  1. Go to Plugins → Add New in your WordPress dashboard
  2. Search for “Custom Post Type UI”
  3. Click Install Now and then Activate the plugin

Step 2: Create and Configure Custom Post Types

  1. Navigate to CPT UI → Add/Edit Post Types in your WordPress dashboard
  2. Enter a name for your custom post type in the Post Type Slug field
  3. Fill in the Plural Label and Singular Label fields
  4. Scroll down to configure additional settings:
    • Set Public to “True” to make the post type visible in the admin UI
    • Enable Show in REST API if you plan to use the block editor
    • Under Supports, check the features you want (title, editor, thumbnail, etc.)
  5. Click Add Post Type to save your new custom post type

Step 3: Create Template Files for Your Custom Post Type

  1. In your child theme, create a file named single-{post-type-slug}.php
    • Replace {post-type-slug} with the slug you defined in Step 2
    • For example, if your post type is “product”, create single-product.php
  2. You can copy the content from your theme’s single.php file as a starting point
  3. Customize the template to match your specific needs for this post type

Step 4: Create an Archive Template (Optional)

  1. Create a file named archive-{post-type-slug}.php in your child theme
  2. Customize this template to control how your custom post type archives appear

Once you’ve set up your custom post type and created the template files, your new content type will appear in the WordPress admin menu. You can then create and manage posts with your custom layout.

Custom Post Type UI works seamlessly with WooCommerce, allowing you to create specialized product types with custom fields and templates. You can extend your store’s functionality by creating custom post types for specific product categories, promotional items, or any specialized content your store needs.

Conclusion

Custom post type templates allow you to use a new layout for your posts alongside the standard WordPress templates, such as single-{post-type}.php or archive-{post-type}.php.

In this post we’ve looked at 2 ways to create custom post type templates: either you edit the single.php file manually, or you install a plugin. Hopefully between them, you’ll find a method that works for you.