Back to Community

How to Enable Page Attributes and Template Selection for Custom Post Types

25 threads Sep 16, 2025 PluginCustom post type ui

Content

If you've created a custom post type (CPT) with the Custom Post Type UI plugin and found that the Page Attributes meta box, particularly the Template dropdown, is missing, you're not alone. This is a common point of confusion that stems from how WordPress core handles templates for custom post types.

Why This Happens

Unlike standard Pages, custom post types do not automatically inherit the ability to select a page template from a dropdown. The Template dropdown is a feature native to the built-in 'page' post type. When you enable the 'Page Attributes' option in Custom Post Type UI, it primarily controls the 'Parent' page dropdown and the 'Order' field, not necessarily the template selector.

The Core WordPress Solution

Starting with WordPress 4.7, the platform introduced a more robust method for assigning templates to any post type. The solution involves creating template files in your theme that are specifically named for your custom post type.

Here is the most common method to enable template selection:

  1. Create a Template File in Your Theme: Add a new file to your active (preferably child) theme's directory. The filename must follow this structure to be recognized by WordPress:
    // For a single post view of a CPT with the slug 'my_cpt'
    single-my_cpt.php
    
    // For an archive view of a CPT with the slug 'my_cpt'
    archive-my_cpt.php
    
  2. Add a Template Header Comment (Optional): To make a template appear in the dropdown menu within the WordPress editor, you can add a special comment at the top of any PHP template file. This method works for any post type, including your custom ones.
    <?php
    /**
     * Template Name: My Custom Layout
     * Template Post Type: my_cpt, post, page
     */
    ?>
    
    The Template Post Type: line is key. List the slugs of the post types you want this template to be available for, separated by commas. In this example, the template becomes available for the custom post type 'my_cpt', as well as standard posts and pages.

Important Considerations

  • Child Theme Recommended: Always make these changes in a child theme. This prevents your modifications from being overwritten when the parent theme is updated.
  • Theme Support Varies: The ability to use the Template Post Type header depends on your theme's structure. Most modern themes support it, but if you encounter issues, you may need to consult your theme's documentation.
  • This is a WordPress Feature: It's important to understand that this functionality is provided by WordPress core. The Custom Post Type UI plugin provides the interface to register the post type, but the template system is handled entirely by WordPress.

By following these steps, you can successfully create and assign custom templates to the post types you manage with Custom Post Type UI, giving you greater control over the layout and design of your content.

Related Support Threads Support