The default_template_types WordPress PHP filter allows you to modify the list of default template types.
Usage
add_filter('default_template_types', 'my_custom_default_template_types'); function my_custom_default_template_types($default_template_types) { // your custom code here return $default_template_types; }
Parameters
$default_template_types
(array): An array of template types, formatted as[ slug => [ title, description ] ]
.
More information
See WordPress Developer Resources: default_template_types
Examples
Add a custom template type
Add a new custom template type to the list of default template types.
add_filter('default_template_types', 'add_custom_template_type'); function add_custom_template_type($default_template_types) { $default_template_types['my_custom_type'] = ['My Custom Type', 'A custom template type for special pages']; return $default_template_types; }
Modify an existing template type
Change the title and description of an existing template type.
add_filter('default_template_types', 'modify_existing_template_type'); function modify_existing_template_type($default_template_types) { $default_template_types['page']['title'] = 'Custom Page'; $default_template_types['page']['description'] = 'A modified page template type'; return $default_template_types; }
Remove a template type
Remove an existing template type from the list.
add_filter('default_template_types', 'remove_template_type'); function remove_template_type($default_template_types) { unset($default_template_types['attachment']); return $default_template_types; }
Replace all template types
Replace the entire list of default template types with a custom list.
add_filter('default_template_types', 'replace_all_template_types'); function replace_all_template_types($default_template_types) { $custom_template_types = [ 'custom_type1' => ['Custom Type 1', 'A custom template type for special pages'], 'custom_type2' => ['Custom Type 2', 'Another custom template type for specific pages'] ]; return $custom_template_types; }
Add a prefix to all template type titles
Add a prefix to the title of all existing template types.
add_filter('default_template_types', 'prefix_template_type_titles'); function prefix_template_type_titles($default_template_types) { foreach ($default_template_types as $slug => $type) { $default_template_types[$slug]['title'] = 'Prefix - ' . $type['title']; } return $default_template_types; }